ras-mce-handler: store 64-bit MCE registers as INT64 - #264
Closed
agenticode wants to merge 1 commit into
Closed
agenticode wants to merge 1 commit into
agenticode wants to merge 1 commit into
Conversation
mcgcap, mcgstatus and ppin are uint64_t in struct mce_event, but mce_record_fields[] declares them as DB_TYPE_INT32. The sqlite3 backend binds those with sqlite3_bind_int(), so the upper 32 bits are dropped on INSERT and the value is sign-extended on read. ppin is the one that matters: it is a 64-bit processor serial, so two CPUs sharing the low 32 bits end up with the same value. 0x123456789abcdef0 and 0x000000009abcdef0 both read back as -1698898192. Use DB_TYPE_INT64 for the three fields. sqlite3 maps INT32 and INT64 to the same column type (INTEGER), so existing databases keep working with no migration. On MySQL and PostgreSQL new tables get BIGINT instead of INT; existing tables are untouched, as db_alter_table() only adds columns. Extend test_mc_event_recording() to check that the MSR-backed fields survive a round trip. Signed-off-by: Jongwon Lee <ai@linux.com>
Owner
|
Applied, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
struct mce_eventhasmcgcap,mcgstatusandppinasuint64_t, butmce_record_fields[]declares those columns asDB_TYPE_INT32. sqlite3 binds them withsqlite3_bind_int(), so the top 32 bits are dropped on INSERT and the value is sign-extended on read.ppinis the one that matters: it is a 64-bit processor serial, so two CPUs sharing the low 32 bits collide.Injecting ppin
0x123456789abcdef0and0x000000009abcdef0throughras_event_publish():before
after
These three are the only columns in the tree where the bound value is wider than the column type.
No migration needed:
db_sqlite3_get_sql_type()returns INTEGER for both INT32 and INT64, and the generated schema is identical before and after. MySQL/PostgreSQL get BIGINT instead of INT on new tables; existing tables are untouched sincedb_alter_table()only adds columns.This is not
DB_TYPE_UINT32/DB_TYPE_UINT64from TODO item 4 - that needs a representation decision and a migration path. Fields with bit 63 set (statusalways hasMCI_STATUS_VAL) still read back negative, but the bits are kept.Tested on Ubuntu 26.04 (gcc 15.2) and Fedora 44 (clang 22.1):
meson test: 9/9 OK with both compilers, no build warningspython3 tests/run.py: 140 tests, rc=0scripts/checkpatch.pl --no-tree --strict: 0 errors, 0 warnings, 0 checksras-mce-handler.chunk fails the new check:[ ERROR ] --- -1698898192 != 1311768467463790320