Skip to content

Commit 513e4dd

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

File tree

7 files changed

+580
-194
lines changed

7 files changed

+580
-194
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: 10 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
};
@@ -183,6 +185,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
183185
#define V_GIF_SHIFT 9
184186
#define V_GIF_MASK (1 << V_GIF_SHIFT)
185187

188+
#define V_INT_SHADOW 10
189+
#define V_INT_SHADOW_MASK (1 << V_INT_SHADOW)
190+
186191
#define V_NMI_PENDING_SHIFT 11
187192
#define V_NMI_PENDING_MASK (1 << V_NMI_PENDING_SHIFT)
188193

@@ -195,6 +200,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
195200
#define V_IGN_TPR_SHIFT 20
196201
#define V_IGN_TPR_MASK (1 << V_IGN_TPR_SHIFT)
197202

203+
#define V_GUEST_BUSY_SHIFT 63
204+
#define V_GUEST_BUSY_MASK (1ULL << V_GUEST_BUSY_SHIFT)
205+
198206
#define V_IRQ_INJECTION_BITS_MASK (V_IRQ_MASK | V_INTR_PRIO_MASK | V_IGN_TPR_MASK)
199207

200208
#define V_INTR_MASKING_SHIFT 24

arch/x86/include/uapi/asm/svm.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@
9494
#define SVM_EXIT_CR13_WRITE_TRAP 0x09d
9595
#define SVM_EXIT_CR14_WRITE_TRAP 0x09e
9696
#define SVM_EXIT_CR15_WRITE_TRAP 0x09f
97-
#define SVM_EXIT_INVPCID 0x0a2
98-
#define SVM_EXIT_NPF 0x400
97+
#define SVM_EXIT_INVPCID 0x0a2
98+
#define SVM_EXIT_BUSLOCK 0x0a5
99+
#define SVM_EXIT_IDLE_HLT 0x0a6
100+
#define SVM_EXIT_NPF 0x400
99101
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
100102
#define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402
101103
#define SVM_EXIT_VMGEXIT 0x403

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)