[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v6 02/12] microcode/intel: use union to get fields without shifting and masking



Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
---
 xen/arch/x86/microcode_intel.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/microcode_intel.c b/xen/arch/x86/microcode_intel.c
index 9657575..22fdeca 100644
--- a/xen/arch/x86/microcode_intel.c
+++ b/xen/arch/x86/microcode_intel.c
@@ -37,7 +37,14 @@
 struct microcode_header_intel {
     unsigned int hdrver;
     unsigned int rev;
-    unsigned int date;
+    union {
+        struct {
+            uint16_t year;
+            uint8_t day;
+            uint8_t month;
+        };
+        unsigned int date;
+    };
     unsigned int sig;
     unsigned int cksum;
     unsigned int ldrver;
@@ -316,9 +323,9 @@ static int apply_microcode(unsigned int cpu)
     printk(KERN_INFO "microcode: CPU%d updated from revision "
            "%#x to %#x, date = %04x-%02x-%02x \n",
            cpu_num, uci->cpu_sig.rev, val[1],
-           uci->mc.mc_intel->hdr.date & 0xffff,
-           uci->mc.mc_intel->hdr.date >> 24,
-           (uci->mc.mc_intel->hdr.date >> 16) & 0xff);
+           uci->mc.mc_intel->hdr.year,
+           uci->mc.mc_intel->hdr.month,
+           uci->mc.mc_intel->hdr.day);
     uci->cpu_sig.rev = val[1];
 
     return 0;
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.