Skip to content

Commit 439328b

Browse files
committed
drivers: hv: mshv_vtl: Support for Secure AVIC
1 parent 8b8b39e commit 439328b

File tree

6 files changed

+467
-193
lines changed

6 files changed

+467
-193
lines changed

arch/x86/include/asm/apic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ static inline u64 native_x2apic_icr_read(void)
245245
extern void x2apic_savic_update_vector(unsigned int cpu,
246246
unsigned int vector,
247247
bool set);
248+
extern void x2apic_savic_init_backing_page(void *backing_page);
248249
#else
249250
static inline void x2apic_savic_update_vector(unsigned int cpu,
250251
unsigned int vector, bool set) { }

arch/x86/include/asm/sev.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ struct rmp_state {
109109
u32 asid;
110110
} __packed;
111111

112-
#define RMPADJUST_VMSA_PAGE_BIT BIT(16)
112+
/* Target VMPL takes the first byte */
113+
#define RMPADJUST_ENABLE_READ BIT(8)
114+
#define RMPADJUST_ENABLE_WRITE BIT(9)
115+
#define RMPADJUST_USER_EXECUTE BIT(10)
116+
#define RMPADJUST_KERNEL_EXECUTE BIT(11)
117+
#define RMPADJUST_VMSA_PAGE_BIT BIT(16)
113118

114119
/* SNP Guest message request */
115120
struct snp_req_data {

arch/x86/include/asm/svm.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include <uapi/asm/svm.h>
66
#include <uapi/asm/kvm.h>
77

8-
#include <asm/hyperv-tlfs.h>
8+
/* TODO: including into mshv_vtl_main.c breaks the build. */
9+
// #include <asm/hyperv-tlfs.h>
910

1011
/*
1112
* 32-bit intercept words in the VMCB Control Area, starting
@@ -164,7 +165,8 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
164165
* for use by hypervisor/software.
165166
*/
166167
union {
167-
struct hv_vmcb_enlightenments hv_enlightenments;
168+
/* TODO: including into mshv_vtl_main.c breaks the build. */
169+
// struct hv_vmcb_enlightenments hv_enlightenments;
168170
u8 reserved_sw[32];
169171
};
170172
};
@@ -195,6 +197,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
195197
#define V_IGN_TPR_SHIFT 20
196198
#define V_IGN_TPR_MASK (1 << V_IGN_TPR_SHIFT)
197199

200+
#define V_GUEST_BUSY_SHIFT 63
201+
#define V_GUEST_BUSY_MASK (1ULL << V_GUEST_BUSY_SHIFT)
202+
198203
#define V_IRQ_INJECTION_BITS_MASK (V_IRQ_MASK | V_INTR_PRIO_MASK | V_IGN_TPR_MASK)
199204

200205
#define V_INTR_MASKING_SHIFT 24

arch/x86/kernel/apic/x2apic_savic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ void x2apic_savic_update_vector(unsigned int cpu, unsigned int vector, bool set)
362362
test_and_clear_bit(VEC_POS(vector), reg);
363363
}
364364

365-
static void init_backing_page(void *backing_page)
365+
void x2apic_savic_init_backing_page(void *backing_page)
366366
{
367367
u32 hv_apic_id;
368368
u32 apic_id;
@@ -412,7 +412,7 @@ static void x2apic_savic_setup(void)
412412
return;
413413

414414
backing_page = this_cpu_read(apic_backing_page);
415-
init_backing_page(backing_page);
415+
x2apic_savic_init_backing_page(backing_page);
416416
gpa = __pa(backing_page);
417417
gfn = gpa >> PAGE_SHIFT;
418418

0 commit comments

Comments
 (0)