]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/apic: Read and write LVT* APIC registers from HV for SAVIC guests
authorNeeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Thu, 28 Aug 2025 11:13:56 +0000 (16:43 +0530)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 1 Sep 2025 11:02:11 +0000 (13:02 +0200)
The Hypervisor needs information about the current state of the LVT registers
for device emulation and NMIs. So, forward reads and write of these registers
to the hypervisor for Secure AVIC enabled guests.

Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tianyu Lan <tiala@microsoft.com>
Link: https://lore.kernel.org/20250828111356.208972-1-Neeraj.Upadhyay@amd.com
arch/x86/kernel/apic/x2apic_savic.c

index bbaedb48a7fbbbe11cf7ad0885895bc779d241a6..b6d6e7a69c89de23be9b565c5a1207be900d7de6 100644 (file)
@@ -67,6 +67,11 @@ static u32 savic_read(u32 reg)
        case APIC_TMICT:
        case APIC_TMCCT:
        case APIC_TDCR:
+       case APIC_LVTTHMR:
+       case APIC_LVTPC:
+       case APIC_LVT0:
+       case APIC_LVT1:
+       case APIC_LVTERR:
                return savic_ghcb_msr_read(reg);
        case APIC_ID:
        case APIC_LVR:
@@ -76,11 +81,6 @@ static u32 savic_read(u32 reg)
        case APIC_LDR:
        case APIC_SPIV:
        case APIC_ESR:
-       case APIC_LVTTHMR:
-       case APIC_LVTPC:
-       case APIC_LVT0:
-       case APIC_LVT1:
-       case APIC_LVTERR:
        case APIC_EFEAT:
        case APIC_ECTRL:
        case APIC_SEOI:
@@ -205,18 +205,18 @@ static void savic_write(u32 reg, u32 data)
        case APIC_LVTT:
        case APIC_TMICT:
        case APIC_TDCR:
-               savic_ghcb_msr_write(reg, data);
-               break;
        case APIC_LVT0:
        case APIC_LVT1:
+       case APIC_LVTTHMR:
+       case APIC_LVTPC:
+       case APIC_LVTERR:
+               savic_ghcb_msr_write(reg, data);
+               break;
        case APIC_TASKPRI:
        case APIC_EOI:
        case APIC_SPIV:
        case SAVIC_NMI_REQ:
        case APIC_ESR:
-       case APIC_LVTTHMR:
-       case APIC_LVTPC:
-       case APIC_LVTERR:
        case APIC_ECTRL:
        case APIC_SEOI:
        case APIC_IER: