Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/64s/exception: Move KVM test to common code

This allows more code to be moved out of unrelocated regions. The
system call KVMTEST is changed to be open-coded and remain in the
tramp area to avoid having to move it to entry_64.S. The custom nature
of the system call entry code means the hcall case can be made more
streamlined than regular interrupt handlers.

mpe: Incorporate fix from Nick:

Moving KVM test to the common entry code missed the case of HMI and
MCE, which do not do __GEN_COMMON_ENTRY (because they don't want to
switch to virt mode).

This means a MCE or HMI exception that is taken while KVM is running a
guest context will not be switched out of that context, and KVM won't
be notified. Found by running sigfuz in guest with patched host on
POWER9 DD2.3, which causes some TM related HMI interrupts (which are
expected and supposed to be handled by KVM).

This fix adds a __GEN_REALMODE_COMMON_ENTRY for those handlers to add
the KVM test. This makes them look a little more like other handlers
that all use __GEN_COMMON_ENTRY.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200225173541.1549955-13-npiggin@gmail.com

authored by

Nicholas Piggin and committed by
Michael Ellerman
9600f261 0eddf327

+139 -139
+139 -121
arch/powerpc/kernel/exceptions-64s.S
··· 44 44 * EXC_VIRT_BEGIN/END - virt (AIL), unrelocated exception vectors 45 45 * TRAMP_REAL_BEGIN - real, unrelocated helpers (virt may call these) 46 46 * TRAMP_VIRT_BEGIN - virt, unreloc helpers (in practice, real can use) 47 - * TRAMP_KVM_BEGIN - KVM handlers, these are put into real, unrelocated 48 47 * EXC_COMMON - After switching to virtual, relocated mode. 49 48 */ 50 49 ··· 72 73 73 74 #define TRAMP_VIRT_BEGIN(name) \ 74 75 FIXED_SECTION_ENTRY_BEGIN(virt_trampolines, name) 75 - 76 - #ifdef CONFIG_KVM_BOOK3S_64_HANDLER 77 - #define TRAMP_KVM_BEGIN(name) \ 78 - TRAMP_VIRT_BEGIN(name) 79 - #else 80 - #define TRAMP_KVM_BEGIN(name) 81 - #endif 82 76 83 77 #define EXC_REAL_NONE(start, size) \ 84 78 FIXED_SECTION_ENTRY_BEGIN_LOCATION(real_vectors, exc_real_##start##_##unused, start, size); \ ··· 263 271 .endm 264 272 265 273 .macro GEN_KVM name 274 + .balign IFETCH_ALIGN_BYTES 275 + \name\()_kvm: 276 + 266 277 .if IKVM_SKIP 267 278 cmpwi r10,KVM_GUEST_MODE_SKIP 268 279 beq 89f ··· 276 281 END_FTR_SECTION_NESTED(CPU_FTR_CFAR,CPU_FTR_CFAR,947) 277 282 .endif 278 283 284 + ld r10,PACA_EXGEN+EX_CTR(r13) 285 + mtctr r10 279 286 BEGIN_FTR_SECTION_NESTED(948) 280 287 ld r10,IAREA+EX_PPR(r13) 281 288 std r10,HSTATE_PPR(r13) 282 289 END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948) 283 - ld r10,IAREA+EX_R10(r13) 290 + ld r11,IAREA+EX_R11(r13) 291 + ld r12,IAREA+EX_R12(r13) 284 292 std r12,HSTATE_SCRATCH0(r13) 285 293 sldi r12,r9,32 294 + ld r9,IAREA+EX_R9(r13) 295 + ld r10,IAREA+EX_R10(r13) 286 296 /* HSRR variants have the 0x2 bit added to their trap number */ 287 297 .if IHSRR == EXC_HV_OR_STD 288 298 BEGIN_FTR_SECTION ··· 300 300 .else 301 301 ori r12,r12,(IVEC) 302 302 .endif 303 - 304 - #ifdef CONFIG_RELOCATABLE 305 - /* 306 - * KVM requires __LOAD_FAR_HANDLER beause kvmppc_interrupt lives 307 - * outside the head section. CONFIG_RELOCATABLE KVM expects CTR 308 - * to be saved in HSTATE_SCRATCH1. 309 - */ 310 - ld r9,IAREA+EX_CTR(r13) 311 - std r9,HSTATE_SCRATCH1(r13) 312 - __LOAD_FAR_HANDLER(r9, kvmppc_interrupt) 313 - mtctr r9 314 - ld r9,IAREA+EX_R9(r13) 315 - bctr 316 - #else 317 - ld r9,IAREA+EX_R9(r13) 318 303 b kvmppc_interrupt 319 - #endif 320 - 321 304 322 305 .if IKVM_SKIP 323 306 89: mtocrf 0x80,r9 307 + ld r10,PACA_EXGEN+EX_CTR(r13) 308 + mtctr r10 324 309 ld r9,IAREA+EX_R9(r13) 325 310 ld r10,IAREA+EX_R10(r13) 311 + ld r11,IAREA+EX_R11(r13) 312 + ld r12,IAREA+EX_R12(r13) 326 313 .if IHSRR == EXC_HV_OR_STD 327 314 BEGIN_FTR_SECTION 328 315 b kvmppc_skip_Hinterrupt ··· 394 407 mfctr r10 395 408 std r10,IAREA+EX_CTR(r13) 396 409 mfcr r9 397 - 398 - .if (!\virt && IKVM_REAL) || (\virt && IKVM_VIRT) 399 - KVMTEST \name IHSRR IVEC 400 - .endif 401 - 402 410 std r11,IAREA+EX_R11(r13) 403 411 std r12,IAREA+EX_R12(r13) 404 412 ··· 451 469 452 470 /* 453 471 * __GEN_COMMON_ENTRY is required to receive the branch from interrupt 454 - * entry, except in the case of the IEARLY handlers. 472 + * entry, except in the case of the real-mode handlers which require 473 + * __GEN_REALMODE_COMMON_ENTRY. 474 + * 455 475 * This switches to virtual mode and sets MSR[RI]. 456 476 */ 457 477 .macro __GEN_COMMON_ENTRY name 458 478 DEFINE_FIXED_SYMBOL(\name\()_common_real) 459 479 \name\()_common_real: 480 + .if IKVM_REAL 481 + KVMTEST \name IHSRR IVEC 482 + .endif 483 + 460 484 ld r10,PACAKMSR(r13) /* get MSR value for kernel */ 461 485 /* MSR[RI] is clear iff using SRR regs */ 462 486 .if IHSRR == EXC_HV_OR_STD ··· 475 487 mtmsrd r10 476 488 477 489 .if IVIRT 490 + .if IKVM_VIRT 491 + b 1f /* skip the virt test coming from real */ 492 + .endif 493 + 478 494 .balign IFETCH_ALIGN_BYTES 479 495 DEFINE_FIXED_SYMBOL(\name\()_common_virt) 480 496 \name\()_common_virt: 497 + .if IKVM_VIRT 498 + KVMTEST \name IHSRR IVEC 499 + 1: 500 + .endif 481 501 .endif /* IVIRT */ 502 + .endm 503 + 504 + /* 505 + * Don't switch to virt mode. Used for early MCE and HMI handlers that 506 + * want to run in real mode. 507 + */ 508 + .macro __GEN_REALMODE_COMMON_ENTRY name 509 + DEFINE_FIXED_SYMBOL(\name\()_common_real) 510 + \name\()_common_real: 511 + .if IKVM_REAL 512 + KVMTEST \name IHSRR IVEC 513 + .endif 482 514 .endm 483 515 484 516 .macro __GEN_COMMON_BODY name ··· 856 848 */ 857 849 EXC_REAL_END(system_reset, 0x100, 0x100) 858 850 EXC_VIRT_NONE(0x4100, 0x100) 859 - TRAMP_KVM_BEGIN(system_reset_kvm) 860 - GEN_KVM system_reset 861 851 862 852 #ifdef CONFIG_PPC_P7_NAP 863 853 TRAMP_REAL_BEGIN(system_reset_idle_wake) ··· 933 927 EXCEPTION_RESTORE_REGS EXC_STD 934 928 RFI_TO_USER_OR_KERNEL 935 929 930 + GEN_KVM system_reset 931 + 936 932 937 933 INT_DEFINE_BEGIN(machine_check_early) 938 934 IVEC=0x200 ··· 976 968 GEN_INT_ENTRY machine_check_early, virt=0 977 969 #endif 978 970 979 - TRAMP_KVM_BEGIN(machine_check_kvm) 980 - GEN_KVM machine_check 981 - 982 971 #define MACHINE_CHECK_HANDLER_WINDUP \ 983 972 /* Clear MSR_RI before setting SRR0 and SRR1. */\ 984 973 li r9,0; \ ··· 989 984 EXC_COMMON_BEGIN(machine_check_early_common) 990 985 mfspr r11,SPRN_SRR0 991 986 mfspr r12,SPRN_SRR1 987 + 988 + __GEN_REALMODE_COMMON_ENTRY machine_check_early 992 989 993 990 /* 994 991 * Switch to mc_emergency stack and handle re-entrancy (we limit ··· 1133 1126 bl machine_check_exception 1134 1127 b ret_from_except 1135 1128 1129 + GEN_KVM machine_check 1130 + 1131 + 1136 1132 #ifdef CONFIG_PPC_P7_NAP 1137 1133 /* 1138 1134 * This is an idle wakeup. Low level machine check has already been ··· 1228 1218 EXC_VIRT_BEGIN(data_access, 0x4300, 0x80) 1229 1219 GEN_INT_ENTRY data_access, virt=1 1230 1220 EXC_VIRT_END(data_access, 0x4300, 0x80) 1231 - TRAMP_KVM_BEGIN(data_access_kvm) 1232 - GEN_KVM data_access 1233 1221 EXC_COMMON_BEGIN(data_access_common) 1234 1222 GEN_COMMON data_access 1235 1223 ld r4,_DAR(r1) ··· 1239 1231 MMU_FTR_SECTION_ELSE 1240 1232 b handle_page_fault 1241 1233 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) 1234 + 1235 + GEN_KVM data_access 1242 1236 1243 1237 1244 1238 INT_DEFINE_BEGIN(data_access_slb) ··· 1258 1248 EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80) 1259 1249 GEN_INT_ENTRY data_access_slb, virt=1 1260 1250 EXC_VIRT_END(data_access_slb, 0x4380, 0x80) 1261 - TRAMP_KVM_BEGIN(data_access_slb_kvm) 1262 - GEN_KVM data_access_slb 1263 1251 EXC_COMMON_BEGIN(data_access_slb_common) 1264 1252 GEN_COMMON data_access_slb 1265 1253 ld r4,_DAR(r1) ··· 1282 1274 bl do_bad_slb_fault 1283 1275 b ret_from_except 1284 1276 1277 + GEN_KVM data_access_slb 1278 + 1285 1279 1286 1280 INT_DEFINE_BEGIN(instruction_access) 1287 1281 IVEC=0x400 ··· 1299 1289 EXC_VIRT_BEGIN(instruction_access, 0x4400, 0x80) 1300 1290 GEN_INT_ENTRY instruction_access, virt=1 1301 1291 EXC_VIRT_END(instruction_access, 0x4400, 0x80) 1302 - TRAMP_KVM_BEGIN(instruction_access_kvm) 1303 - GEN_KVM instruction_access 1304 1292 EXC_COMMON_BEGIN(instruction_access_common) 1305 1293 GEN_COMMON instruction_access 1306 1294 ld r4,_DAR(r1) ··· 1310 1302 MMU_FTR_SECTION_ELSE 1311 1303 b handle_page_fault 1312 1304 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) 1305 + 1306 + GEN_KVM instruction_access 1313 1307 1314 1308 1315 1309 INT_DEFINE_BEGIN(instruction_access_slb) ··· 1329 1319 EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x80) 1330 1320 GEN_INT_ENTRY instruction_access_slb, virt=1 1331 1321 EXC_VIRT_END(instruction_access_slb, 0x4480, 0x80) 1332 - TRAMP_KVM_BEGIN(instruction_access_slb_kvm) 1333 - GEN_KVM instruction_access_slb 1334 1322 EXC_COMMON_BEGIN(instruction_access_slb_common) 1335 1323 GEN_COMMON instruction_access_slb 1336 1324 ld r4,_DAR(r1) ··· 1353 1345 bl do_bad_slb_fault 1354 1346 b ret_from_except 1355 1347 1348 + GEN_KVM instruction_access_slb 1349 + 1350 + 1356 1351 INT_DEFINE_BEGIN(hardware_interrupt) 1357 1352 IVEC=0x500 1358 1353 IHSRR=EXC_HV_OR_STD ··· 1370 1359 EXC_VIRT_BEGIN(hardware_interrupt, 0x4500, 0x100) 1371 1360 GEN_INT_ENTRY hardware_interrupt, virt=1 1372 1361 EXC_VIRT_END(hardware_interrupt, 0x4500, 0x100) 1373 - TRAMP_KVM_BEGIN(hardware_interrupt_kvm) 1374 - GEN_KVM hardware_interrupt 1375 1362 EXC_COMMON_BEGIN(hardware_interrupt_common) 1376 1363 GEN_COMMON hardware_interrupt 1377 1364 FINISH_NAP ··· 1377 1368 addi r3,r1,STACK_FRAME_OVERHEAD 1378 1369 bl do_IRQ 1379 1370 b ret_from_except_lite 1371 + 1372 + GEN_KVM hardware_interrupt 1380 1373 1381 1374 1382 1375 INT_DEFINE_BEGIN(alignment) ··· 1394 1383 EXC_VIRT_BEGIN(alignment, 0x4600, 0x100) 1395 1384 GEN_INT_ENTRY alignment, virt=1 1396 1385 EXC_VIRT_END(alignment, 0x4600, 0x100) 1397 - TRAMP_KVM_BEGIN(alignment_kvm) 1398 - GEN_KVM alignment 1399 1386 EXC_COMMON_BEGIN(alignment_common) 1400 1387 GEN_COMMON alignment 1401 1388 bl save_nvgprs 1402 1389 addi r3,r1,STACK_FRAME_OVERHEAD 1403 1390 bl alignment_exception 1404 1391 b ret_from_except 1392 + 1393 + GEN_KVM alignment 1405 1394 1406 1395 1407 1396 INT_DEFINE_BEGIN(program_check) ··· 1415 1404 EXC_VIRT_BEGIN(program_check, 0x4700, 0x100) 1416 1405 GEN_INT_ENTRY program_check, virt=1 1417 1406 EXC_VIRT_END(program_check, 0x4700, 0x100) 1418 - TRAMP_KVM_BEGIN(program_check_kvm) 1419 - GEN_KVM program_check 1420 1407 EXC_COMMON_BEGIN(program_check_common) 1421 1408 __GEN_COMMON_ENTRY program_check 1422 1409 ··· 1454 1445 bl program_check_exception 1455 1446 b ret_from_except 1456 1447 1448 + GEN_KVM program_check 1449 + 1457 1450 1458 1451 INT_DEFINE_BEGIN(fp_unavailable) 1459 1452 IVEC=0x800 ··· 1469 1458 EXC_VIRT_BEGIN(fp_unavailable, 0x4800, 0x100) 1470 1459 GEN_INT_ENTRY fp_unavailable, virt=1 1471 1460 EXC_VIRT_END(fp_unavailable, 0x4800, 0x100) 1472 - TRAMP_KVM_BEGIN(fp_unavailable_kvm) 1473 - GEN_KVM fp_unavailable 1474 1461 EXC_COMMON_BEGIN(fp_unavailable_common) 1475 1462 GEN_COMMON fp_unavailable 1476 1463 bne 1f /* if from user, just load it up */ ··· 1499 1490 b ret_from_except 1500 1491 #endif 1501 1492 1493 + GEN_KVM fp_unavailable 1494 + 1502 1495 1503 1496 INT_DEFINE_BEGIN(decrementer) 1504 1497 IVEC=0x900 ··· 1514 1503 EXC_VIRT_BEGIN(decrementer, 0x4900, 0x80) 1515 1504 GEN_INT_ENTRY decrementer, virt=1 1516 1505 EXC_VIRT_END(decrementer, 0x4900, 0x80) 1517 - TRAMP_KVM_BEGIN(decrementer_kvm) 1518 - GEN_KVM decrementer 1519 1506 EXC_COMMON_BEGIN(decrementer_common) 1520 1507 GEN_COMMON decrementer 1521 1508 FINISH_NAP ··· 1521 1512 addi r3,r1,STACK_FRAME_OVERHEAD 1522 1513 bl timer_interrupt 1523 1514 b ret_from_except_lite 1515 + 1516 + GEN_KVM decrementer 1524 1517 1525 1518 1526 1519 INT_DEFINE_BEGIN(hdecrementer) ··· 1538 1527 EXC_VIRT_BEGIN(hdecrementer, 0x4980, 0x80) 1539 1528 GEN_INT_ENTRY hdecrementer, virt=1 1540 1529 EXC_VIRT_END(hdecrementer, 0x4980, 0x80) 1541 - TRAMP_KVM_BEGIN(hdecrementer_kvm) 1542 - GEN_KVM hdecrementer 1543 1530 EXC_COMMON_BEGIN(hdecrementer_common) 1544 1531 GEN_COMMON hdecrementer 1545 1532 bl save_nvgprs 1546 1533 addi r3,r1,STACK_FRAME_OVERHEAD 1547 1534 bl hdec_interrupt 1548 1535 b ret_from_except 1536 + 1537 + GEN_KVM hdecrementer 1549 1538 1550 1539 1551 1540 INT_DEFINE_BEGIN(doorbell_super) ··· 1560 1549 EXC_VIRT_BEGIN(doorbell_super, 0x4a00, 0x100) 1561 1550 GEN_INT_ENTRY doorbell_super, virt=1 1562 1551 EXC_VIRT_END(doorbell_super, 0x4a00, 0x100) 1563 - TRAMP_KVM_BEGIN(doorbell_super_kvm) 1564 - GEN_KVM doorbell_super 1565 1552 EXC_COMMON_BEGIN(doorbell_super_common) 1566 1553 GEN_COMMON doorbell_super 1567 1554 FINISH_NAP ··· 1571 1562 bl unknown_exception 1572 1563 #endif 1573 1564 b ret_from_except_lite 1565 + 1566 + GEN_KVM doorbell_super 1574 1567 1575 1568 1576 1569 EXC_REAL_NONE(0xb00, 0x100) ··· 1678 1667 EXC_VIRT_END(system_call, 0x4c00, 0x100) 1679 1668 1680 1669 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER 1670 + TRAMP_REAL_BEGIN(system_call_kvm) 1681 1671 /* 1682 1672 * This is a hcall, so register convention is as above, with these 1683 1673 * differences: ··· 1686 1674 * ctr = orig r13 1687 1675 * orig r10 saved in PACA 1688 1676 */ 1689 - TRAMP_KVM_BEGIN(system_call_kvm) 1690 1677 /* 1691 1678 * Save the PPR (on systems that support it) before changing to 1692 1679 * HMT_MEDIUM. That allows the KVM code to save that value into the 1693 1680 * guest state (it is the guest's PPR value). 1694 1681 */ 1695 - OPT_GET_SPR(r10, SPRN_PPR, CPU_FTR_HAS_PPR) 1682 + BEGIN_FTR_SECTION_NESTED(948) 1683 + mfspr r10,SPRN_PPR 1684 + std r10,HSTATE_PPR(r13) 1685 + END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948) 1696 1686 HMT_MEDIUM 1697 - OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r10, CPU_FTR_HAS_PPR) 1698 1687 mfctr r10 1699 1688 SET_SCRATCH0(r10) 1700 - std r9,PACA_EXGEN+EX_R9(r13) 1701 - mfcr r9 1702 - GEN_KVM system_call 1689 + mfcr r10 1690 + std r12,HSTATE_SCRATCH0(r13) 1691 + sldi r12,r10,32 1692 + ori r12,r12,0xc00 1693 + #ifdef CONFIG_RELOCATABLE 1694 + /* 1695 + * Requires __LOAD_FAR_HANDLER beause kvmppc_interrupt lives 1696 + * outside the head section. 1697 + */ 1698 + __LOAD_FAR_HANDLER(r10, kvmppc_interrupt) 1699 + mtctr r10 1700 + ld r10,PACA_EXGEN+EX_R10(r13) 1701 + bctr 1702 + #else 1703 + ld r10,PACA_EXGEN+EX_R10(r13) 1704 + b kvmppc_interrupt 1705 + #endif 1703 1706 #endif 1704 1707 1705 1708 ··· 1729 1702 EXC_VIRT_BEGIN(single_step, 0x4d00, 0x100) 1730 1703 GEN_INT_ENTRY single_step, virt=1 1731 1704 EXC_VIRT_END(single_step, 0x4d00, 0x100) 1732 - TRAMP_KVM_BEGIN(single_step_kvm) 1733 - GEN_KVM single_step 1734 1705 EXC_COMMON_BEGIN(single_step_common) 1735 1706 GEN_COMMON single_step 1736 1707 bl save_nvgprs 1737 1708 addi r3,r1,STACK_FRAME_OVERHEAD 1738 1709 bl single_step_exception 1739 1710 b ret_from_except 1711 + 1712 + GEN_KVM single_step 1740 1713 1741 1714 1742 1715 INT_DEFINE_BEGIN(h_data_storage) ··· 1755 1728 EXC_VIRT_BEGIN(h_data_storage, 0x4e00, 0x20) 1756 1729 GEN_INT_ENTRY h_data_storage, virt=1, ool=1 1757 1730 EXC_VIRT_END(h_data_storage, 0x4e00, 0x20) 1758 - TRAMP_KVM_BEGIN(h_data_storage_kvm) 1759 - GEN_KVM h_data_storage 1760 1731 EXC_COMMON_BEGIN(h_data_storage_common) 1761 1732 GEN_COMMON h_data_storage 1762 1733 bl save_nvgprs ··· 1767 1742 bl unknown_exception 1768 1743 ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_TYPE_RADIX) 1769 1744 b ret_from_except 1745 + 1746 + GEN_KVM h_data_storage 1770 1747 1771 1748 1772 1749 INT_DEFINE_BEGIN(h_instr_storage) ··· 1784 1757 EXC_VIRT_BEGIN(h_instr_storage, 0x4e20, 0x20) 1785 1758 GEN_INT_ENTRY h_instr_storage, virt=1, ool=1 1786 1759 EXC_VIRT_END(h_instr_storage, 0x4e20, 0x20) 1787 - TRAMP_KVM_BEGIN(h_instr_storage_kvm) 1788 - GEN_KVM h_instr_storage 1789 1760 EXC_COMMON_BEGIN(h_instr_storage_common) 1790 1761 GEN_COMMON h_instr_storage 1791 1762 bl save_nvgprs 1792 1763 addi r3,r1,STACK_FRAME_OVERHEAD 1793 1764 bl unknown_exception 1794 1765 b ret_from_except 1766 + 1767 + GEN_KVM h_instr_storage 1795 1768 1796 1769 1797 1770 INT_DEFINE_BEGIN(emulation_assist) ··· 1807 1780 EXC_VIRT_BEGIN(emulation_assist, 0x4e40, 0x20) 1808 1781 GEN_INT_ENTRY emulation_assist, virt=1, ool=1 1809 1782 EXC_VIRT_END(emulation_assist, 0x4e40, 0x20) 1810 - TRAMP_KVM_BEGIN(emulation_assist_kvm) 1811 - GEN_KVM emulation_assist 1812 1783 EXC_COMMON_BEGIN(emulation_assist_common) 1813 1784 GEN_COMMON emulation_assist 1814 1785 bl save_nvgprs 1815 1786 addi r3,r1,STACK_FRAME_OVERHEAD 1816 1787 bl emulation_assist_interrupt 1817 1788 b ret_from_except 1789 + 1790 + GEN_KVM emulation_assist 1818 1791 1819 1792 1820 1793 /* ··· 1843 1816 GEN_INT_ENTRY hmi_exception_early, virt=0, ool=1 1844 1817 EXC_REAL_END(hmi_exception, 0xe60, 0x20) 1845 1818 EXC_VIRT_NONE(0x4e60, 0x20) 1846 - TRAMP_KVM_BEGIN(hmi_exception_early_kvm) 1847 - GEN_KVM hmi_exception_early 1848 - TRAMP_KVM_BEGIN(hmi_exception_kvm) 1849 - GEN_KVM hmi_exception 1850 1819 1851 1820 EXC_COMMON_BEGIN(hmi_exception_early_common) 1852 1821 mfspr r11,SPRN_HSRR0 /* Save HSRR0 */ 1853 1822 mfspr r12,SPRN_HSRR1 /* Save HSRR1 */ 1823 + 1824 + __GEN_REALMODE_COMMON_ENTRY hmi_exception_early 1825 + 1854 1826 mr r10,r1 /* Save r1 */ 1855 1827 ld r1,PACAEMERGSP(r13) /* Use emergency stack for realmode */ 1856 1828 subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ ··· 1872 1846 EXCEPTION_RESTORE_REGS EXC_HV 1873 1847 GEN_INT_ENTRY hmi_exception, virt=0 1874 1848 1849 + GEN_KVM hmi_exception_early 1850 + 1875 1851 EXC_COMMON_BEGIN(hmi_exception_common) 1876 1852 GEN_COMMON hmi_exception 1877 1853 FINISH_NAP ··· 1882 1854 addi r3,r1,STACK_FRAME_OVERHEAD 1883 1855 bl handle_hmi_exception 1884 1856 b ret_from_except 1857 + 1858 + GEN_KVM hmi_exception 1885 1859 1886 1860 1887 1861 INT_DEFINE_BEGIN(h_doorbell) ··· 1900 1870 EXC_VIRT_BEGIN(h_doorbell, 0x4e80, 0x20) 1901 1871 GEN_INT_ENTRY h_doorbell, virt=1, ool=1 1902 1872 EXC_VIRT_END(h_doorbell, 0x4e80, 0x20) 1903 - TRAMP_KVM_BEGIN(h_doorbell_kvm) 1904 - GEN_KVM h_doorbell 1905 1873 EXC_COMMON_BEGIN(h_doorbell_common) 1906 1874 GEN_COMMON h_doorbell 1907 1875 FINISH_NAP ··· 1911 1883 bl unknown_exception 1912 1884 #endif 1913 1885 b ret_from_except_lite 1886 + 1887 + GEN_KVM h_doorbell 1914 1888 1915 1889 1916 1890 INT_DEFINE_BEGIN(h_virt_irq) ··· 1929 1899 EXC_VIRT_BEGIN(h_virt_irq, 0x4ea0, 0x20) 1930 1900 GEN_INT_ENTRY h_virt_irq, virt=1, ool=1 1931 1901 EXC_VIRT_END(h_virt_irq, 0x4ea0, 0x20) 1932 - TRAMP_KVM_BEGIN(h_virt_irq_kvm) 1933 - GEN_KVM h_virt_irq 1934 1902 EXC_COMMON_BEGIN(h_virt_irq_common) 1935 1903 GEN_COMMON h_virt_irq 1936 1904 FINISH_NAP ··· 1936 1908 addi r3,r1,STACK_FRAME_OVERHEAD 1937 1909 bl do_IRQ 1938 1910 b ret_from_except_lite 1911 + 1912 + GEN_KVM h_virt_irq 1939 1913 1940 1914 1941 1915 EXC_REAL_NONE(0xec0, 0x20) ··· 1958 1928 EXC_VIRT_BEGIN(performance_monitor, 0x4f00, 0x20) 1959 1929 GEN_INT_ENTRY performance_monitor, virt=1, ool=1 1960 1930 EXC_VIRT_END(performance_monitor, 0x4f00, 0x20) 1961 - TRAMP_KVM_BEGIN(performance_monitor_kvm) 1962 - GEN_KVM performance_monitor 1963 1931 EXC_COMMON_BEGIN(performance_monitor_common) 1964 1932 GEN_COMMON performance_monitor 1965 1933 FINISH_NAP ··· 1965 1937 addi r3,r1,STACK_FRAME_OVERHEAD 1966 1938 bl performance_monitor_exception 1967 1939 b ret_from_except_lite 1940 + 1941 + GEN_KVM performance_monitor 1968 1942 1969 1943 1970 1944 INT_DEFINE_BEGIN(altivec_unavailable) ··· 1981 1951 EXC_VIRT_BEGIN(altivec_unavailable, 0x4f20, 0x20) 1982 1952 GEN_INT_ENTRY altivec_unavailable, virt=1, ool=1 1983 1953 EXC_VIRT_END(altivec_unavailable, 0x4f20, 0x20) 1984 - TRAMP_KVM_BEGIN(altivec_unavailable_kvm) 1985 - GEN_KVM altivec_unavailable 1986 1954 EXC_COMMON_BEGIN(altivec_unavailable_common) 1987 1955 GEN_COMMON altivec_unavailable 1988 1956 #ifdef CONFIG_ALTIVEC ··· 2014 1986 bl altivec_unavailable_exception 2015 1987 b ret_from_except 2016 1988 1989 + GEN_KVM altivec_unavailable 1990 + 2017 1991 2018 1992 INT_DEFINE_BEGIN(vsx_unavailable) 2019 1993 IVEC=0xf40 ··· 2029 1999 EXC_VIRT_BEGIN(vsx_unavailable, 0x4f40, 0x20) 2030 2000 GEN_INT_ENTRY vsx_unavailable, virt=1, ool=1 2031 2001 EXC_VIRT_END(vsx_unavailable, 0x4f40, 0x20) 2032 - TRAMP_KVM_BEGIN(vsx_unavailable_kvm) 2033 - GEN_KVM vsx_unavailable 2034 2002 EXC_COMMON_BEGIN(vsx_unavailable_common) 2035 2003 GEN_COMMON vsx_unavailable 2036 2004 #ifdef CONFIG_VSX ··· 2061 2033 bl vsx_unavailable_exception 2062 2034 b ret_from_except 2063 2035 2036 + GEN_KVM vsx_unavailable 2037 + 2064 2038 2065 2039 INT_DEFINE_BEGIN(facility_unavailable) 2066 2040 IVEC=0xf60 ··· 2075 2045 EXC_VIRT_BEGIN(facility_unavailable, 0x4f60, 0x20) 2076 2046 GEN_INT_ENTRY facility_unavailable, virt=1, ool=1 2077 2047 EXC_VIRT_END(facility_unavailable, 0x4f60, 0x20) 2078 - TRAMP_KVM_BEGIN(facility_unavailable_kvm) 2079 - GEN_KVM facility_unavailable 2080 2048 EXC_COMMON_BEGIN(facility_unavailable_common) 2081 2049 GEN_COMMON facility_unavailable 2082 2050 bl save_nvgprs 2083 2051 addi r3,r1,STACK_FRAME_OVERHEAD 2084 2052 bl facility_unavailable_exception 2085 2053 b ret_from_except 2054 + 2055 + GEN_KVM facility_unavailable 2086 2056 2087 2057 2088 2058 INT_DEFINE_BEGIN(h_facility_unavailable) ··· 2098 2068 EXC_VIRT_BEGIN(h_facility_unavailable, 0x4f80, 0x20) 2099 2069 GEN_INT_ENTRY h_facility_unavailable, virt=1, ool=1 2100 2070 EXC_VIRT_END(h_facility_unavailable, 0x4f80, 0x20) 2101 - TRAMP_KVM_BEGIN(h_facility_unavailable_kvm) 2102 - GEN_KVM h_facility_unavailable 2103 2071 EXC_COMMON_BEGIN(h_facility_unavailable_common) 2104 2072 GEN_COMMON h_facility_unavailable 2105 2073 bl save_nvgprs 2106 2074 addi r3,r1,STACK_FRAME_OVERHEAD 2107 2075 bl facility_unavailable_exception 2108 2076 b ret_from_except 2077 + 2078 + GEN_KVM h_facility_unavailable 2109 2079 2110 2080 2111 2081 EXC_REAL_NONE(0xfa0, 0x20) ··· 2132 2102 GEN_INT_ENTRY cbe_system_error, virt=0 2133 2103 EXC_REAL_END(cbe_system_error, 0x1200, 0x100) 2134 2104 EXC_VIRT_NONE(0x5200, 0x100) 2135 - TRAMP_KVM_BEGIN(cbe_system_error_kvm) 2136 - GEN_KVM cbe_system_error 2137 2105 EXC_COMMON_BEGIN(cbe_system_error_common) 2138 2106 GEN_COMMON cbe_system_error 2139 2107 bl save_nvgprs 2140 2108 addi r3,r1,STACK_FRAME_OVERHEAD 2141 2109 bl cbe_system_error_exception 2142 2110 b ret_from_except 2111 + 2112 + GEN_KVM cbe_system_error 2113 + 2143 2114 #else /* CONFIG_CBE_RAS */ 2144 2115 EXC_REAL_NONE(0x1200, 0x100) 2145 2116 EXC_VIRT_NONE(0x5200, 0x100) ··· 2159 2128 EXC_VIRT_BEGIN(instruction_breakpoint, 0x5300, 0x100) 2160 2129 GEN_INT_ENTRY instruction_breakpoint, virt=1 2161 2130 EXC_VIRT_END(instruction_breakpoint, 0x5300, 0x100) 2162 - TRAMP_KVM_BEGIN(instruction_breakpoint_kvm) 2163 - GEN_KVM instruction_breakpoint 2164 2131 EXC_COMMON_BEGIN(instruction_breakpoint_common) 2165 2132 GEN_COMMON instruction_breakpoint 2166 2133 bl save_nvgprs 2167 2134 addi r3,r1,STACK_FRAME_OVERHEAD 2168 2135 bl instruction_breakpoint_exception 2169 2136 b ret_from_except 2137 + 2138 + GEN_KVM instruction_breakpoint 2170 2139 2171 2140 2172 2141 EXC_REAL_NONE(0x1400, 0x100) ··· 2176 2145 IVEC=0x1500 2177 2146 IHSRR=EXC_HV 2178 2147 IEARLY=2 2148 + IKVM_REAL=1 2179 2149 INT_DEFINE_END(denorm_exception) 2180 2150 2181 2151 EXC_REAL_BEGIN(denorm_exception, 0x1500, 0x100) ··· 2186 2154 andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ 2187 2155 bne+ denorm_assist 2188 2156 #endif 2189 - KVMTEST denorm_exception, EXC_HV, 0x1500 2190 2157 mfspr r11,SPRN_HSRR0 2191 2158 mfspr r12,SPRN_HSRR1 2192 2159 GEN_BRANCH_TO_COMMON denorm_exception, virt=0 ··· 2203 2172 #else 2204 2173 EXC_VIRT_NONE(0x5500, 0x100) 2205 2174 #endif 2206 - TRAMP_KVM_BEGIN(denorm_exception_kvm) 2207 - GEN_KVM denorm_exception 2208 2175 2209 2176 #ifdef CONFIG_PPC_DENORMALISATION 2210 2177 TRAMP_REAL_BEGIN(denorm_assist) ··· 2280 2251 bl unknown_exception 2281 2252 b ret_from_except 2282 2253 2254 + GEN_KVM denorm_exception 2255 + 2283 2256 2284 2257 #ifdef CONFIG_CBE_RAS 2285 2258 INT_DEFINE_BEGIN(cbe_maintenance) ··· 2295 2264 GEN_INT_ENTRY cbe_maintenance, virt=0 2296 2265 EXC_REAL_END(cbe_maintenance, 0x1600, 0x100) 2297 2266 EXC_VIRT_NONE(0x5600, 0x100) 2298 - TRAMP_KVM_BEGIN(cbe_maintenance_kvm) 2299 - GEN_KVM cbe_maintenance 2300 2267 EXC_COMMON_BEGIN(cbe_maintenance_common) 2301 2268 GEN_COMMON cbe_maintenance 2302 2269 bl save_nvgprs 2303 2270 addi r3,r1,STACK_FRAME_OVERHEAD 2304 2271 bl cbe_maintenance_exception 2305 2272 b ret_from_except 2273 + 2274 + GEN_KVM cbe_maintenance 2275 + 2306 2276 #else /* CONFIG_CBE_RAS */ 2307 2277 EXC_REAL_NONE(0x1600, 0x100) 2308 2278 EXC_VIRT_NONE(0x5600, 0x100) ··· 2321 2289 EXC_VIRT_BEGIN(altivec_assist, 0x5700, 0x100) 2322 2290 GEN_INT_ENTRY altivec_assist, virt=1 2323 2291 EXC_VIRT_END(altivec_assist, 0x5700, 0x100) 2324 - TRAMP_KVM_BEGIN(altivec_assist_kvm) 2325 - GEN_KVM altivec_assist 2326 2292 EXC_COMMON_BEGIN(altivec_assist_common) 2327 2293 GEN_COMMON altivec_assist 2328 2294 bl save_nvgprs ··· 2331 2301 bl unknown_exception 2332 2302 #endif 2333 2303 b ret_from_except 2304 + 2305 + GEN_KVM altivec_assist 2334 2306 2335 2307 2336 2308 #ifdef CONFIG_CBE_RAS ··· 2347 2315 GEN_INT_ENTRY cbe_thermal, virt=0 2348 2316 EXC_REAL_END(cbe_thermal, 0x1800, 0x100) 2349 2317 EXC_VIRT_NONE(0x5800, 0x100) 2350 - TRAMP_KVM_BEGIN(cbe_thermal_kvm) 2351 - GEN_KVM cbe_thermal 2352 2318 EXC_COMMON_BEGIN(cbe_thermal_common) 2353 2319 GEN_COMMON cbe_thermal 2354 2320 bl save_nvgprs 2355 2321 addi r3,r1,STACK_FRAME_OVERHEAD 2356 2322 bl cbe_thermal_exception 2357 2323 b ret_from_except 2324 + 2325 + GEN_KVM cbe_thermal 2326 + 2358 2327 #else /* CONFIG_CBE_RAS */ 2359 2328 EXC_REAL_NONE(0x1800, 0x100) 2360 2329 EXC_VIRT_NONE(0x5800, 0x100) ··· 2547 2514 GET_SCRATCH0(r13); 2548 2515 hrfid 2549 2516 2550 - /* 2551 - * Real mode exceptions actually use this too, but alternate 2552 - * instruction code patches (which end up in the common .text area) 2553 - * cannot reach these if they are put there. 2554 - */ 2555 2517 USE_TEXT_SECTION() 2556 2518 MASKED_INTERRUPT EXC_STD 2557 2519 MASKED_INTERRUPT EXC_HV 2558 2520 2559 2521 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER 2560 - TRAMP_REAL_BEGIN(kvmppc_skip_interrupt) 2522 + kvmppc_skip_interrupt: 2561 2523 /* 2562 2524 * Here all GPRs are unchanged from when the interrupt happened 2563 2525 * except for r13, which is saved in SPRG_SCRATCH0. ··· 2564 2536 RFI_TO_KERNEL 2565 2537 b . 2566 2538 2567 - TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt) 2539 + kvmppc_skip_Hinterrupt: 2568 2540 /* 2569 2541 * Here all GPRs are unchanged from when the interrupt happened 2570 2542 * except for r13, which is saved in SPRG_SCRATCH0. ··· 2576 2548 HRFI_TO_KERNEL 2577 2549 b . 2578 2550 #endif 2579 - 2580 - /* 2581 - * Ensure that any handlers that get invoked from the exception prologs 2582 - * above are below the first 64KB (0x10000) of the kernel image because 2583 - * the prologs assemble the addresses of these handlers using the 2584 - * LOAD_HANDLER macro, which uses an ori instruction. 2585 - */ 2586 - 2587 - /*** Common interrupt handlers ***/ 2588 - 2589 2551 2590 2552 /* 2591 2553 * Relocation-on interrupts: A subset of the interrupts can be delivered
-11
arch/powerpc/kvm/book3s_hv_rmhandlers.S
··· 1266 1266 * R12 = (guest CR << 32) | interrupt vector 1267 1267 * R13 = PACA 1268 1268 * guest R12 saved in shadow VCPU SCRATCH0 1269 - * guest CTR saved in shadow VCPU SCRATCH1 if RELOCATABLE 1270 1269 * guest R13 saved in SPRN_SCRATCH0 1271 1270 */ 1272 1271 std r9, HSTATE_SCRATCH2(r13) ··· 1366 1367 11: stw r3,VCPU_HEIR(r9) 1367 1368 1368 1369 /* these are volatile across C function calls */ 1369 - #ifdef CONFIG_RELOCATABLE 1370 - ld r3, HSTATE_SCRATCH1(r13) 1371 - mtctr r3 1372 - #else 1373 1370 mfctr r3 1374 - #endif 1375 1371 mfxer r4 1376 1372 std r3, VCPU_CTR(r9) 1377 1373 std r4, VCPU_XER(r9) ··· 3252 3258 * r12 is (CR << 32) | vector 3253 3259 * r13 points to our PACA 3254 3260 * r12 is saved in HSTATE_SCRATCH0(r13) 3255 - * ctr is saved in HSTATE_SCRATCH1(r13) if RELOCATABLE 3256 3261 * r9 is saved in HSTATE_SCRATCH2(r13) 3257 3262 * r13 is saved in HSPRG1 3258 3263 * cfar is saved in HSTATE_CFAR(r13) ··· 3300 3307 ld r5, HSTATE_CFAR(r13) 3301 3308 std r5, ORIG_GPR3(r1) 3302 3309 mflr r3 3303 - #ifdef CONFIG_RELOCATABLE 3304 - ld r4, HSTATE_SCRATCH1(r13) 3305 - #else 3306 3310 mfctr r4 3307 - #endif 3308 3311 mfxer r5 3309 3312 lbz r6, PACAIRQSOFTMASK(r13) 3310 3313 std r3, _LINK(r1)
-7
arch/powerpc/kvm/book3s_segment.S
··· 167 167 * R12 = (guest CR << 32) | exit handler id 168 168 * R13 = PACA 169 169 * HSTATE.SCRATCH0 = guest R12 170 - * HSTATE.SCRATCH1 = guest CTR if RELOCATABLE 171 170 */ 172 171 #ifdef CONFIG_PPC64 173 172 /* Match 32-bit entry */ 174 - #ifdef CONFIG_RELOCATABLE 175 - std r9, HSTATE_SCRATCH2(r13) 176 - ld r9, HSTATE_SCRATCH1(r13) 177 - mtctr r9 178 - ld r9, HSTATE_SCRATCH2(r13) 179 - #endif 180 173 rotldi r12, r12, 32 /* Flip R12 halves for stw */ 181 174 stw r12, HSTATE_SCRATCH1(r13) /* CR is now in the low half */ 182 175 srdi r12, r12, 32 /* shift trap into low half */