Skip to content

Commit 5bb6c1d

Browse files
committed
Revert "x86/sev: Expose sev_es_ghcb_hv_call() for use by HyperV"
This reverts commit 007faec. Now that hyperv does its own protocol negotiation: 49d6a3c ("x86/Hyper-V: Add SEV negotiate protocol support in Isolation VM") revert this exposure of the sev_es_ghcb_hv_call() helper. Cc: Wei Liu <wei.liu@kernel.org> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by:Tianyu Lan <tiala@microsoft.com> Link: https://lore.kernel.org/r/20220614014553.1915929-1-ltykernel@gmail.com
1 parent 871808f commit 5bb6c1d

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

arch/x86/include/asm/sev.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ static inline u64 lower_bits(u64 val, unsigned int bits)
7272

7373
struct real_mode_header;
7474
enum stack_type;
75-
struct ghcb;
7675

7776
/* Early IDT entry points for #VC handler */
7877
extern void vc_no_ghcb(void);
@@ -156,11 +155,7 @@ static __always_inline void sev_es_nmi_complete(void)
156155
__sev_es_nmi_complete();
157156
}
158157
extern int __init sev_es_efi_map_ghcbs(pgd_t *pgd);
159-
extern enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
160-
bool set_ghcb_msr,
161-
struct es_em_ctxt *ctxt,
162-
u64 exit_code, u64 exit_info_1,
163-
u64 exit_info_2);
158+
164159
static inline int rmpadjust(unsigned long vaddr, bool rmp_psize, unsigned long attrs)
165160
{
166161
int rc;

arch/x86/kernel/sev-shared.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,10 @@ static enum es_result verify_exception_info(struct ghcb *ghcb, struct es_em_ctxt
219219
return ES_VMM_ERROR;
220220
}
221221

222-
enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, bool set_ghcb_msr,
223-
struct es_em_ctxt *ctxt, u64 exit_code,
224-
u64 exit_info_1, u64 exit_info_2)
222+
static enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
223+
struct es_em_ctxt *ctxt,
224+
u64 exit_code, u64 exit_info_1,
225+
u64 exit_info_2)
225226
{
226227
/* Fill in protocol and format specifiers */
227228
ghcb->protocol_version = ghcb_version;
@@ -231,14 +232,7 @@ enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, bool set_ghcb_msr,
231232
ghcb_set_sw_exit_info_1(ghcb, exit_info_1);
232233
ghcb_set_sw_exit_info_2(ghcb, exit_info_2);
233234

234-
/*
235-
* Hyper-V unenlightened guests use a paravisor for communicating and
236-
* GHCB pages are being allocated and set up by that paravisor. Linux
237-
* should not change the GHCB page's physical address.
238-
*/
239-
if (set_ghcb_msr)
240-
sev_es_wr_ghcb_msr(__pa(ghcb));
241-
235+
sev_es_wr_ghcb_msr(__pa(ghcb));
242236
VMGEXIT();
243237

244238
return verify_exception_info(ghcb, ctxt);
@@ -795,7 +789,7 @@ static enum es_result vc_handle_ioio(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
795789
*/
796790
sw_scratch = __pa(ghcb) + offsetof(struct ghcb, shared_buffer);
797791
ghcb_set_sw_scratch(ghcb, sw_scratch);
798-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt, SVM_EXIT_IOIO,
792+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_IOIO,
799793
exit_info_1, exit_info_2);
800794
if (ret != ES_OK)
801795
return ret;
@@ -837,8 +831,7 @@ static enum es_result vc_handle_ioio(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
837831

838832
ghcb_set_rax(ghcb, rax);
839833

840-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt,
841-
SVM_EXIT_IOIO, exit_info_1, 0);
834+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_IOIO, exit_info_1, 0);
842835
if (ret != ES_OK)
843836
return ret;
844837

@@ -894,7 +887,7 @@ static enum es_result vc_handle_cpuid(struct ghcb *ghcb,
894887
/* xgetbv will cause #GP - use reset value for xcr0 */
895888
ghcb_set_xcr0(ghcb, 1);
896889

897-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt, SVM_EXIT_CPUID, 0, 0);
890+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_CPUID, 0, 0);
898891
if (ret != ES_OK)
899892
return ret;
900893

@@ -919,7 +912,7 @@ static enum es_result vc_handle_rdtsc(struct ghcb *ghcb,
919912
bool rdtscp = (exit_code == SVM_EXIT_RDTSCP);
920913
enum es_result ret;
921914

922-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt, exit_code, 0, 0);
915+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, exit_code, 0, 0);
923916
if (ret != ES_OK)
924917
return ret;
925918

arch/x86/kernel/sev.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ static int vmgexit_psc(struct snp_psc_desc *desc)
786786
ghcb_set_sw_scratch(ghcb, (u64)__pa(data));
787787

788788
/* This will advance the shared buffer data points to. */
789-
ret = sev_es_ghcb_hv_call(ghcb, true, &ctxt, SVM_VMGEXIT_PSC, 0, 0);
789+
ret = sev_es_ghcb_hv_call(ghcb, &ctxt, SVM_VMGEXIT_PSC, 0, 0);
790790

791791
/*
792792
* Page State Change VMGEXIT can pass error code through
@@ -1212,8 +1212,7 @@ static enum es_result vc_handle_msr(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
12121212
ghcb_set_rdx(ghcb, regs->dx);
12131213
}
12141214

1215-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt, SVM_EXIT_MSR,
1216-
exit_info_1, 0);
1215+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_MSR, exit_info_1, 0);
12171216

12181217
if ((ret == ES_OK) && (!exit_info_1)) {
12191218
regs->ax = ghcb->save.rax;
@@ -1452,7 +1451,7 @@ static enum es_result vc_do_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
14521451

14531452
ghcb_set_sw_scratch(ghcb, ghcb_pa + offsetof(struct ghcb, shared_buffer));
14541453

1455-
return sev_es_ghcb_hv_call(ghcb, true, ctxt, exit_code, exit_info_1, exit_info_2);
1454+
return sev_es_ghcb_hv_call(ghcb, ctxt, exit_code, exit_info_1, exit_info_2);
14561455
}
14571456

14581457
/*
@@ -1628,7 +1627,7 @@ static enum es_result vc_handle_dr7_write(struct ghcb *ghcb,
16281627

16291628
/* Using a value of 0 for ExitInfo1 means RAX holds the value */
16301629
ghcb_set_rax(ghcb, val);
1631-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt, SVM_EXIT_WRITE_DR7, 0, 0);
1630+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_WRITE_DR7, 0, 0);
16321631
if (ret != ES_OK)
16331632
return ret;
16341633

@@ -1658,7 +1657,7 @@ static enum es_result vc_handle_dr7_read(struct ghcb *ghcb,
16581657
static enum es_result vc_handle_wbinvd(struct ghcb *ghcb,
16591658
struct es_em_ctxt *ctxt)
16601659
{
1661-
return sev_es_ghcb_hv_call(ghcb, true, ctxt, SVM_EXIT_WBINVD, 0, 0);
1660+
return sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_WBINVD, 0, 0);
16621661
}
16631662

16641663
static enum es_result vc_handle_rdpmc(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
@@ -1667,7 +1666,7 @@ static enum es_result vc_handle_rdpmc(struct ghcb *ghcb, struct es_em_ctxt *ctxt
16671666

16681667
ghcb_set_rcx(ghcb, ctxt->regs->cx);
16691668

1670-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt, SVM_EXIT_RDPMC, 0, 0);
1669+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_RDPMC, 0, 0);
16711670
if (ret != ES_OK)
16721671
return ret;
16731672

@@ -1708,7 +1707,7 @@ static enum es_result vc_handle_vmmcall(struct ghcb *ghcb,
17081707
if (x86_platform.hyper.sev_es_hcall_prepare)
17091708
x86_platform.hyper.sev_es_hcall_prepare(ghcb, ctxt->regs);
17101709

1711-
ret = sev_es_ghcb_hv_call(ghcb, true, ctxt, SVM_EXIT_VMMCALL, 0, 0);
1710+
ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_VMMCALL, 0, 0);
17121711
if (ret != ES_OK)
17131712
return ret;
17141713

@@ -2197,7 +2196,7 @@ int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned
21972196
ghcb_set_rbx(ghcb, input->data_npages);
21982197
}
21992198

2200-
ret = sev_es_ghcb_hv_call(ghcb, true, &ctxt, exit_code, input->req_gpa, input->resp_gpa);
2199+
ret = sev_es_ghcb_hv_call(ghcb, &ctxt, exit_code, input->req_gpa, input->resp_gpa);
22012200
if (ret)
22022201
goto e_put;
22032202

0 commit comments

Comments
 (0)