Skip to content

Commit 31a40e2

Browse files
paulusmackmpe
authored andcommitted
powerpc/64: Include KVM guest test in all interrupt vectors
Currently, if HV KVM is configured but PR KVM isn't, we don't include a test to see whether we were interrupted in KVM guest context for the set of interrupts which get delivered directly to the guest by hardware if they occur in the guest. This includes things like program interrupts. However, the recent bug where userspace could set the MSR for a VCPU to have an illegal value in the TS field, and thus cause a TM Bad Thing type of program interrupt on the hrfid that enters the guest, showed that we can never be completely sure that these interrupts can never occur in the guest entry/exit code. If one of these interrupts does happen and we have HV KVM configured but not PR KVM, then we end up trying to run the handler in the host with the MMU set to the guest MMU context, which generally ends badly. Thus, for robustness it is better to have the test in every interrupt vector, so that if some way is found to trigger some interrupt in the guest entry/exit path, we can handle it without immediately crashing the host. This means that the distinction between KVMTEST and KVMTEST_PR goes away. Thus we delete KVMTEST_PR and associated macros and use KVMTEST everywhere that we previously used either KVMTEST_PR or KVMTEST. It also means that SOFTEN_TEST_HV_201 becomes the same as SOFTEN_TEST_PR, so we deleted SOFTEN_TEST_HV_201 and use SOFTEN_TEST_PR instead. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent b4f8144 commit 31a40e2

File tree

2 files changed

+20
-35
lines changed

2 files changed

+20
-35
lines changed

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,6 @@ do_kvm_##n: \
263263
#define KVM_HANDLER_SKIP(area, h, n)
264264
#endif
265265

266-
#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
267-
#define KVMTEST_PR(n) __KVMTEST(n)
268-
#define KVM_HANDLER_PR(area, h, n) __KVM_HANDLER(area, h, n)
269-
#define KVM_HANDLER_PR_SKIP(area, h, n) __KVM_HANDLER_SKIP(area, h, n)
270-
271-
#else
272-
#define KVMTEST_PR(n)
273-
#define KVM_HANDLER_PR(area, h, n)
274-
#define KVM_HANDLER_PR_SKIP(area, h, n)
275-
#endif
276-
277266
#define NOTEST(n)
278267

279268
/*
@@ -360,13 +349,13 @@ label##_pSeries: \
360349
HMT_MEDIUM_PPR_DISCARD; \
361350
SET_SCRATCH0(r13); /* save r13 */ \
362351
EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, \
363-
EXC_STD, KVMTEST_PR, vec)
352+
EXC_STD, KVMTEST, vec)
364353

365354
/* Version of above for when we have to branch out-of-line */
366355
#define STD_EXCEPTION_PSERIES_OOL(vec, label) \
367356
.globl label##_pSeries; \
368357
label##_pSeries: \
369-
EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, vec); \
358+
EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST, vec); \
370359
EXCEPTION_PROLOG_PSERIES_1(label##_common, EXC_STD)
371360

372361
#define STD_EXCEPTION_HV(loc, vec, label) \
@@ -436,17 +425,13 @@ label##_relon_hv: \
436425
#define _SOFTEN_TEST(h, vec) __SOFTEN_TEST(h, vec)
437426

438427
#define SOFTEN_TEST_PR(vec) \
439-
KVMTEST_PR(vec); \
428+
KVMTEST(vec); \
440429
_SOFTEN_TEST(EXC_STD, vec)
441430

442431
#define SOFTEN_TEST_HV(vec) \
443432
KVMTEST(vec); \
444433
_SOFTEN_TEST(EXC_HV, vec)
445434

446-
#define SOFTEN_TEST_HV_201(vec) \
447-
KVMTEST(vec); \
448-
_SOFTEN_TEST(EXC_STD, vec)
449-
450435
#define SOFTEN_NOTEST_PR(vec) _SOFTEN_TEST(EXC_STD, vec)
451436
#define SOFTEN_NOTEST_HV(vec) _SOFTEN_TEST(EXC_HV, vec)
452437

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ instruction_access_slb_pSeries:
242242
HMT_MEDIUM_PPR_DISCARD
243243
SET_SCRATCH0(r13)
244244
EXCEPTION_PROLOG_0(PACA_EXSLB)
245-
EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
245+
EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x480)
246246
std r3,PACA_EXSLB+EX_R3(r13)
247247
mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
248248
#ifdef __DISABLED__
@@ -276,18 +276,18 @@ hardware_interrupt_hv:
276276
KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502)
277277
FTR_SECTION_ELSE
278278
_MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt,
279-
EXC_STD, SOFTEN_TEST_HV_201)
279+
EXC_STD, SOFTEN_TEST_PR)
280280
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500)
281281
ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
282282

283283
STD_EXCEPTION_PSERIES(0x600, 0x600, alignment)
284-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600)
284+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x600)
285285

286286
STD_EXCEPTION_PSERIES(0x700, 0x700, program_check)
287-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700)
287+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x700)
288288

289289
STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable)
290-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)
290+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x800)
291291

292292
. = 0x900
293293
.globl decrementer_pSeries
@@ -297,10 +297,10 @@ decrementer_pSeries:
297297
STD_EXCEPTION_HV(0x980, 0x982, hdecrementer)
298298

299299
MASKABLE_EXCEPTION_PSERIES(0xa00, 0xa00, doorbell_super)
300-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00)
300+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xa00)
301301

302302
STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b)
303-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00)
303+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xb00)
304304

305305
. = 0xc00
306306
.globl system_call_pSeries
@@ -332,7 +332,7 @@ system_call_pSeries:
332332
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
333333

334334
STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step)
335-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00)
335+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xd00)
336336

337337
/* At 0xe??? we have a bunch of hypervisor exceptions, we branch
338338
* out of line to handle them
@@ -408,7 +408,7 @@ hv_facility_unavailable_trampoline:
408408
#endif /* CONFIG_CBE_RAS */
409409

410410
STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint)
411-
KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
411+
KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
412412

413413
. = 0x1500
414414
.global denorm_exception_hv
@@ -436,7 +436,7 @@ denorm_exception_hv:
436436
#endif /* CONFIG_CBE_RAS */
437437

438438
STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist)
439-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700)
439+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x1700)
440440

441441
#ifdef CONFIG_CBE_RAS
442442
STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
@@ -536,9 +536,9 @@ machine_check_pSeries_0:
536536
KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
537537
KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
538538
KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
539-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
540-
KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
541-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)
539+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x400)
540+
KVM_HANDLER(PACA_EXSLB, EXC_STD, 0x480)
541+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x900)
542542
KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982)
543543

544544
#ifdef CONFIG_PPC_DENORMALISATION
@@ -621,13 +621,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
621621

622622
/* moved from 0xf00 */
623623
STD_EXCEPTION_PSERIES_OOL(0xf00, performance_monitor)
624-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00)
624+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf00)
625625
STD_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
626-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20)
626+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf20)
627627
STD_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
628-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40)
628+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf40)
629629
STD_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
630-
KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf60)
630+
KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xf60)
631631
STD_EXCEPTION_HV_OOL(0xf82, facility_unavailable)
632632
KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xf82)
633633

0 commit comments

Comments
 (0)