Skip to content

Commit bc35512

Browse files
paulusmackmpe
authored andcommitted
powerpc/64: Allow for relocation-on interrupts from guest to host
With host and guest both using radix translation, it is feasible for the host to take interrupts that come from the guest with relocation on, and that is in fact what the POWER9 hardware will do when LPCR[AIL] = 3. All such interrupts use HSRR0/1 not SRR0/1 except for system call with LEV=1 (hcall). Therefore this adds the KVM tests to the _HV variants of the relocation-on interrupt handlers, and adds the KVM test to the relocation-on system call entry point. We also instantiate the relocation-on versions of the hypervisor data storage and instruction interrupt handlers, since these can occur with relocation on in radix guests. Signed-off-by: Paul Mackerras <paulus@ozlabs.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 16ed141 commit bc35512

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

arch/powerpc/include/asm/exception-64s.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,12 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
428428
EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_STD)
429429

430430
#define STD_RELON_EXCEPTION_HV(loc, vec, label) \
431-
/* No guest interrupts come through here */ \
432431
SET_SCRATCH0(r13); /* save r13 */ \
433-
EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, EXC_HV, NOTEST, vec);
432+
EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, \
433+
EXC_HV, KVMTEST_HV, vec);
434434

435435
#define STD_RELON_EXCEPTION_HV_OOL(vec, label) \
436-
EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \
436+
EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \
437437
EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV)
438438

439439
/* This associate vector numbers with bits in paca->irq_happened */
@@ -510,10 +510,10 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
510510

511511
#define MASKABLE_RELON_EXCEPTION_HV(loc, vec, label) \
512512
_MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \
513-
EXC_HV, SOFTEN_NOTEST_HV)
513+
EXC_HV, SOFTEN_TEST_HV)
514514

515515
#define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label) \
516-
EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_NOTEST_HV, vec); \
516+
EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \
517517
EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV)
518518

519519
/*

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,31 @@ EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00)
830830
TRAMP_KVM(PACA_EXGEN, 0xb00)
831831
EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
832832

833+
#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
834+
/*
835+
* If CONFIG_KVM_BOOK3S_64_HANDLER is set, save the PPR (on systems
836+
* that support it) before changing to HMT_MEDIUM. That allows the KVM
837+
* code to save that value into the guest state (it is the guest's PPR
838+
* value). Otherwise just change to HMT_MEDIUM as userspace has
839+
* already saved the PPR.
840+
*/
841+
#define SYSCALL_KVMTEST \
842+
SET_SCRATCH0(r13); \
843+
GET_PACA(r13); \
844+
std r9,PACA_EXGEN+EX_R9(r13); \
845+
OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR); \
846+
HMT_MEDIUM; \
847+
std r10,PACA_EXGEN+EX_R10(r13); \
848+
OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r9, CPU_FTR_HAS_PPR); \
849+
mfcr r9; \
850+
KVMTEST_PR(0xc00); \
851+
GET_SCRATCH0(r13)
852+
853+
#else
854+
#define SYSCALL_KVMTEST \
855+
HMT_MEDIUM
856+
#endif
857+
833858
#define LOAD_SYSCALL_HANDLER(reg) \
834859
__LOAD_HANDLER(reg, system_call_common)
835860

@@ -883,34 +908,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
883908
#endif
884909

885910
EXC_REAL_BEGIN(system_call, 0xc00, 0xd00)
886-
/*
887-
* If CONFIG_KVM_BOOK3S_64_HANDLER is set, save the PPR (on systems
888-
* that support it) before changing to HMT_MEDIUM. That allows the KVM
889-
* code to save that value into the guest state (it is the guest's PPR
890-
* value). Otherwise just change to HMT_MEDIUM as userspace has
891-
* already saved the PPR.
892-
*/
893-
#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
894-
SET_SCRATCH0(r13)
895-
GET_PACA(r13)
896-
std r9,PACA_EXGEN+EX_R9(r13)
897-
OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR);
898-
HMT_MEDIUM;
899-
std r10,PACA_EXGEN+EX_R10(r13)
900-
OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r9, CPU_FTR_HAS_PPR);
901-
mfcr r9
902-
KVMTEST_PR(0xc00)
903-
GET_SCRATCH0(r13)
904-
#else
905-
HMT_MEDIUM;
906-
#endif
911+
SYSCALL_KVMTEST
907912
SYSCALL_PSERIES_1
908913
SYSCALL_PSERIES_2_RFID
909914
SYSCALL_PSERIES_3
910915
EXC_REAL_END(system_call, 0xc00, 0xd00)
911916

912917
EXC_VIRT_BEGIN(system_call, 0x4c00, 0x4d00)
913-
HMT_MEDIUM
918+
SYSCALL_KVMTEST
914919
SYSCALL_PSERIES_1
915920
SYSCALL_PSERIES_2_DIRECT
916921
SYSCALL_PSERIES_3
@@ -925,7 +930,7 @@ TRAMP_KVM(PACA_EXGEN, 0xd00)
925930
EXC_COMMON(single_step_common, 0xd00, single_step_exception)
926931

927932
EXC_REAL_OOL_HV(h_data_storage, 0xe00, 0xe20)
928-
EXC_VIRT_NONE(0x4e00, 0x4e20)
933+
EXC_VIRT_OOL_HV(h_data_storage, 0x4e00, 0x4e20, 0xe00)
929934
TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0xe00)
930935
EXC_COMMON_BEGIN(h_data_storage_common)
931936
mfspr r10,SPRN_HDAR
@@ -941,7 +946,7 @@ EXC_COMMON_BEGIN(h_data_storage_common)
941946

942947

943948
EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0xe40)
944-
EXC_VIRT_NONE(0x4e20, 0x4e40)
949+
EXC_VIRT_OOL_HV(h_instr_storage, 0x4e20, 0x4e40, 0xe20)
945950
TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
946951
EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
947952

0 commit comments

Comments
 (0)