Pull arm64 fixes from Will Deacon: "It's a bit all over the place, as I was hoping to fix a decade-old bug in our seccomp handling on syscall entry and ended up collecting other fixes in the meantime. You'll see the failed attempt (+revert) here but I didn't want to hold off on the others any longer. Hopefully we'll get that one squashed next week... - Fix early_ioremap() of unaligned ACPI tables - Remove bogus information from data abort diagnostics - Fix kprobes recursion during single-step - Fix incorrect constant in ESR address size fault macro - Fix OOB page-table walk in memory hot-unplug notifier - Fix OOB access to the linear map when retrieving an unaligned huge pte - Fix MPAM register reset values - Fix MPAM NULL dereference on teardown" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: make huge_ptep_get handled unaligned addresses arm64/mm: Check the requested PFN range during memory removal arm64: Correct value returned by ESR_ELx_FSC_ADDRSZ_nL() arm64: kprobes: Allow reentering kprobes while single-stepping arm64: kprobes: Only handle faults originating from XOL slot drivers/virt: pkvm: Fix end calculation in mmio_guard_ioremap_hook() Revert "arm64: syscall: Ensure saved x0 is kept in-sync with tracer updates" arm64: mm: When logging data aborts only decode Xs when ISV=1 arm64: fixmap: Allow 256K early_ioremap() at any offset arm_mpam: guard MBWU state before adding it to garbage arm_mpam: Fix MPAMCFG_MBW_PBM register setting arm_mpam: Fix software reset values of MPAMCFG_PRI arm64: syscall: Ensure saved x0 is kept in-sync with tracer updates
Unified · Split
| @@ -131,7 +131,7 @@ · 130 unmodified lines | ||
| 131 | 131 | * Annoyingly, the negative levels for Address size faults aren't laid out |
| 132 | 132 | * contiguously (or in the desired order) |
| 133 | 133 | */ |
| 134 | −#define ESR_ELx_FSC_ADDRSZ_nL(n) ((n) == -1 ? 0x25 : 0x2C) | |
| 134 | +#define ESR_ELx_FSC_ADDRSZ_nL(n) ((n) == -1 ? 0x29 : 0x2C) | |
| 135 | 135 | #define ESR_ELx_FSC_ADDRSZ_L(n) ((n) < 0 ? ESR_ELx_FSC_ADDRSZ_nL(n) : \ |
| 136 | 136 | (ESR_ELx_FSC_ADDRSZ + (n))) |
| 137 | 137 | |
| @@ -78,8 +78,12 @@ enum fixed_addresses { · 77 unmodified lines | ||
| 78 | 78 | /* |
| 79 | 79 | * Temporary boot-time mappings, used by early_ioremap(), |
| 80 | 80 | * before ioremap() is functional. |
| 81 | + * | |
| 82 | + * Reserve one extra page so a 256K mapping may start at any | |
| 83 | + * offset within a page. early_ioremap() maps the page-aligned | |
| 84 | + * physical range, so the initial offset can consume an extra page. | |
| 81 | 85 | */ |
| 82 | −#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) | |
| 86 | +#define NR_FIX_BTMAPS ((SZ_256K / PAGE_SIZE) + 1) | |
| 83 | 87 | #define FIX_BTMAPS_SLOTS 7 |
| 84 | 88 | #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) |
| 85 | 89 | |
| @@ -26,6 +26,12 @@ · 25 unmodified lines | ||
| 26 | 26 | struct prev_kprobe { |
| 27 | 27 | struct kprobe *kp; |
| 28 | 28 | unsigned int status; |
| 29 | + | |
| 30 | + /* | |
| 31 | + * The original DAIF state of the outer kprobe, saved here before | |
| 32 | + * a nested kprobe overwrites kcb->saved_irqflag during reentry. | |
| 33 | + */ | |
| 34 | + unsigned long saved_irqflag; | |
| 29 | 35 | }; |
| 30 | 36 | |
| 31 | 37 | /* per-cpu kprobe control block */ |
| @@ -174,12 +174,27 @@ static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) · 173 unmodified lines | ||
| 174 | 174 | { |
| 175 | 175 | kcb->prev_kprobe.kp = kprobe_running(); |
| 176 | 176 | kcb->prev_kprobe.status = kcb->kprobe_status; |
| 177 | + | |
| 178 | + /* | |
| 179 | + * Save the outer kprobe's original DAIF flags before the nested | |
| 180 | + * kprobe calls kprobes_save_local_irqflag() and overwrites | |
| 181 | + * kcb->saved_irqflag. Without this, the outer kprobe will restore | |
| 182 | + * the wrong DAIF state and leave interrupts permanently masked. | |
| 183 | + */ | |
| 184 | + kcb->prev_kprobe.saved_irqflag = kcb->saved_irqflag; | |
| 177 | 185 | } |
| 178 | 186 | |
| 179 | 187 | static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) |
| 180 | 188 | { |
| 181 | 189 | __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp); |
| 182 | 190 | kcb->kprobe_status = kcb->prev_kprobe.status; |
| 191 | + | |
| 192 | + /* | |
| 193 | + * Restore the outer kprobe's saved_irqflag so that when its | |
| 194 | + * single-step completes, kprobes_restore_local_irqflag() uses | |
| 195 | + * the correct original DAIF value. | |
| 196 | + */ | |
| 197 | + kcb->saved_irqflag = kcb->prev_kprobe.saved_irqflag; | |
| 183 | 198 | } |
| 184 | 199 | |
| 185 | 200 | static void __kprobes set_current_kprobe(struct kprobe *p) |
| @@ -240,10 +255,16 @@ static int __kprobes reenter_kprobe(struct kprobe *p, · 54 unmodified lines | ||
| 240 | 255 | switch (kcb->kprobe_status) { |
| 241 | 256 | case KPROBE_HIT_SSDONE: |
| 242 | 257 | case KPROBE_HIT_ACTIVE: |
| 258 | + case KPROBE_HIT_SS: | |
| 259 | + /* | |
| 260 | + * A probe can be hit while another kprobe is preparing or | |
| 261 | + * executing its XOL single-step instruction. This is still a | |
| 262 | + * recoverable one-level reentry, so handle it in the same way as | |
| 263 | + * reentry from KPROBE_HIT_ACTIVE or KPROBE_HIT_SSDONE. | |
| 264 | + */ | |
| 243 | 265 | kprobes_inc_nmissed_count(p); |
| 244 | 266 | setup_singlestep(p, regs, kcb, 1); |
| 245 | 267 | break; |
| 246 | − case KPROBE_HIT_SS: | |
| 247 | 268 | case KPROBE_REENTER: |
| 248 | 269 | pr_warn("Failed to recover from reentered kprobes.\n"); |
| 249 | 270 | dump_kprobe(p); |
| @@ -282,9 +303,31 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr) · 32 unmodified lines | ||
| 282 | 303 | struct kprobe *cur = kprobe_running(); |
| 283 | 304 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); |
| 284 | 305 | |
| 306 | + /* | |
| 307 | + * Simulated kprobes execute in the debug trap context and have no | |
| 308 | + * XOL slot. Any page fault taken while a simulated kprobe is in | |
| 309 | + * progress cannot have been caused by kprobe single-stepping and | |
| 310 | + * must be left alone for the normal page fault handler, including | |
| 311 | + * fixup_exception. | |
| 312 | + */ | |
| 313 | + if (cur && !cur->ainsn.xol_insn) | |
| 314 | + return 0; | |
| 315 | + | |
| 285 | 316 | switch (kcb->kprobe_status) { |
| 286 | 317 | case KPROBE_HIT_SS: |
| 287 | 318 | case KPROBE_REENTER: |
| 319 | + /* | |
| 320 | + * A page fault taken while in KPROBE_HIT_SS or | |
| 321 | + * KPROBE_REENTER state is only attributable to kprobe | |
| 322 | + * single-stepping if the faulting PC points to the | |
| 323 | + * current kprobe's XOL instruction. If the fault occurred | |
| 324 | + * elsewhere (e.g. in perf or tracing code invoked from the | |
| 325 | + * debug exception path), leave it for the normal page fault | |
| 326 | + * handler to process. | |
| 327 | + */ | |
| 328 | + if (instruction_pointer(regs) != (unsigned long)cur->ainsn.xol_insn) | |
| 329 | + break; | |
| 330 | + | |
| 288 | 331 | /* |
| 289 | 332 | * We are here because the instruction being single |
| 290 | 333 | * stepped caused a page fault. We reset the current |
| @@ -76,6 +76,8 @@ static void data_abort_decode(unsigned long esr) · 75 unmodified lines | ||
| 76 | 76 | pr_alert(" SF = %lu, AR = %lu\n", |
| 77 | 77 | (esr & ESR_ELx_SF) >> ESR_ELx_SF_SHIFT, |
| 78 | 78 | (esr & ESR_ELx_AR) >> ESR_ELx_AR_SHIFT); |
| 79 | + pr_alert(" Xs = %llu\n", | |
| 80 | + (iss2 & ESR_ELx_Xs_MASK) >> ESR_ELx_Xs_SHIFT); | |
| 79 | 81 | } else { |
| 80 | 82 | pr_alert(" ISV = 0, ISS = 0x%08lx, ISS2 = 0x%08lx\n", |
| 81 | 83 | esr & ESR_ELx_ISS_MASK, iss2); |
| @@ -87,11 +89,10 @@ static void data_abort_decode(unsigned long esr) · 5 unmodified lines | ||
| 87 | 89 | (iss2 & ESR_ELx_TnD) >> ESR_ELx_TnD_SHIFT, |
| 88 | 90 | (iss2 & ESR_ELx_TagAccess) >> ESR_ELx_TagAccess_SHIFT); |
| 89 | 91 | |
| 90 | − pr_alert(" GCS = %ld, Overlay = %lu, DirtyBit = %lu, Xs = %llu\n", | |
| 92 | + pr_alert(" GCS = %ld, Overlay = %lu, DirtyBit = %lu\n", | |
| 91 | 93 | (iss2 & ESR_ELx_GCS) >> ESR_ELx_GCS_SHIFT, |
| 92 | 94 | (iss2 & ESR_ELx_Overlay) >> ESR_ELx_Overlay_SHIFT, |
| 93 | − (iss2 & ESR_ELx_DirtyBit) >> ESR_ELx_DirtyBit_SHIFT, | |
| 94 | − (iss2 & ESR_ELx_Xs_MASK) >> ESR_ELx_Xs_SHIFT); | |
| 95 | + (iss2 & ESR_ELx_DirtyBit) >> ESR_ELx_DirtyBit_SHIFT); | |
| 95 | 96 | } |
| 96 | 97 | |
| 97 | 98 | static void mem_abort_decode(unsigned long esr) |
| @@ -87,7 +87,7 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr, · 86 unmodified lines | ||
| 87 | 87 | p4dp = p4d_offset(pgdp, addr); |
| 88 | 88 | pudp = pud_offset(p4dp, addr); |
| 89 | 89 | pmdp = pmd_offset(pudp, addr); |
| 90 | − if ((pte_t *)pmdp == ptep) { | |
| 90 | + if ((pte_t *)PTR_ALIGN_DOWN(pmdp, sizeof(*pmdp) * CONT_PMDS) == ptep) { | |
| 91 | 91 | *pgsize = PMD_SIZE; |
| 92 | 92 | return CONT_PMDS; |
| 93 | 93 | } |
| @@ -2194,7 +2194,7 @@ static int prevent_memory_remove_notifier(struct notifier_block *nb, · 2193 unmodified lines | ||
| 2194 | 2194 | } |
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | − if (!can_unmap_without_split(pfn, arg->nr_pages)) | |
| 2197 | + if (!can_unmap_without_split(arg->start_pfn, arg->nr_pages)) | |
| 2198 | 2198 | return NOTIFY_BAD; |
| 2199 | 2199 | |
| 2200 | 2200 | return NOTIFY_OK; |
| @@ -1552,12 +1552,9 @@ static u16 mpam_wa_t241_calc_min_from_max(struct mpam_props *props, · 1551 unmodified lines | ||
| 1552 | 1552 | static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, |
| 1553 | 1553 | struct mpam_config *cfg) |
| 1554 | 1554 | { |
| 1555 | − u32 pri_val = 0; | |
| 1556 | 1555 | u16 cmax = MPAMCFG_CMAX_CMAX; |
| 1557 | 1556 | struct mpam_msc *msc = ris->vmsc->msc; |
| 1558 | 1557 | struct mpam_props *rprops = &ris->props; |
| 1559 | − u16 dspri = GENMASK(rprops->dspri_wd, 0); | |
| 1560 | − u16 intpri = GENMASK(rprops->intpri_wd, 0); | |
| 1561 | 1558 | |
| 1562 | 1559 | mutex_lock(&msc->part_sel_lock); |
| 1563 | 1560 | __mpam_part_sel(ris->ris_idx, partid, msc); |
| @@ -1583,9 +1580,9 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, · 19 unmodified lines | ||
| 1583 | 1580 | |
| 1584 | 1581 | if (mpam_has_feature(mpam_feat_mbw_part, rprops)) { |
| 1585 | 1582 | if (mpam_has_feature(mpam_feat_mbw_part, cfg)) |
| 1586 | − mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops->mbw_pbm_bits); | |
| 1587 | − else | |
| 1588 | 1583 | mpam_write_partsel_reg(msc, MBW_PBM, cfg->mbw_pbm); |
| 1584 | + else | |
| 1585 | + mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops->mbw_pbm_bits); | |
| 1589 | 1586 | } |
| 1590 | 1587 | |
| 1591 | 1588 | if (mpam_has_feature(mpam_feat_mbw_min, rprops)) { |
| @@ -1622,16 +1619,25 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, · 30 unmodified lines | ||
| 1622 | 1619 | |
| 1623 | 1620 | if (mpam_has_feature(mpam_feat_intpri_part, rprops) || |
| 1624 | 1621 | mpam_has_feature(mpam_feat_dspri_part, rprops)) { |
| 1625 | − /* aces high? */ | |
| 1626 | − if (!mpam_has_feature(mpam_feat_intpri_part_0_low, rprops)) | |
| 1627 | − intpri = 0; | |
| 1628 | − if (!mpam_has_feature(mpam_feat_dspri_part_0_low, rprops)) | |
| 1629 | − dspri = 0; | |
| 1622 | + u32 pri_val = 0; | |
| 1623 | + | |
| 1624 | + if (mpam_has_feature(mpam_feat_intpri_part, rprops)) { | |
| 1625 | + u16 intpri = GENMASK(rprops->intpri_wd - 1, 0); | |
| 1626 | + | |
| 1627 | + /* aces high? */ | |
| 1628 | + if (!mpam_has_feature(mpam_feat_intpri_part_0_low, rprops)) | |
| 1629 | + intpri = 0; | |
| 1630 | 1630 | |
| 1631 | − if (mpam_has_feature(mpam_feat_intpri_part, rprops)) | |
| 1632 | 1631 | pri_val |= FIELD_PREP(MPAMCFG_PRI_INTPRI, intpri); |
| 1633 | − if (mpam_has_feature(mpam_feat_dspri_part, rprops)) | |
| 1632 | + } | |
| 1633 | + if (mpam_has_feature(mpam_feat_dspri_part, rprops)) { | |
| 1634 | + u16 dspri = GENMASK(rprops->dspri_wd - 1, 0); | |
| 1635 | + | |
| 1636 | + if (!mpam_has_feature(mpam_feat_dspri_part_0_low, rprops)) | |
| 1637 | + dspri = 0; | |
| 1638 | + | |
| 1634 | 1639 | pri_val |= FIELD_PREP(MPAMCFG_PRI_DSPRI, dspri); |
| 1640 | + } | |
| 1635 | 1641 | |
| 1636 | 1642 | mpam_write_partsel_reg(msc, PRI, pri_val); |
| 1637 | 1643 | } |
| @@ -2606,8 +2612,10 @@ static void __destroy_component_cfg(struct mpam_component *comp) · 968 unmodified lines | ||
| 2606 | 2612 | msc = vmsc->msc; |
| 2607 | 2613 | |
| 2608 | 2614 | if (mpam_mon_sel_lock(msc)) { |
| 2609 | − list_for_each_entry(ris, &vmsc->ris, vmsc_list) | |
| 2610 | − add_to_garbage(ris->mbwu_state); | |
| 2615 | + list_for_each_entry(ris, &vmsc->ris, vmsc_list) { | |
| 2616 | + if (ris->mbwu_state) | |
| 2617 | + add_to_garbage(ris->mbwu_state); | |
| 2618 | + } | |
| 2611 | 2619 | mpam_mon_sel_unlock(msc); |
| 2612 | 2620 | } |
| 2613 | 2621 | } |
| @@ -82,8 +82,8 @@ static int mmio_guard_ioremap_hook(phys_addr_t phys, size_t size, · 81 unmodified lines | ||
| 82 | 82 | if (protval != PROT_DEVICE_nGnRE && protval != PROT_DEVICE_nGnRnE) |
| 83 | 83 | return 0; |
| 84 | 84 | |
| 85 | + end = PAGE_ALIGN(phys + size); | |
| 85 | 86 | phys = PAGE_ALIGN_DOWN(phys); |
| 86 | − end = phys + PAGE_ALIGN(size); | |
| 87 | 87 | |
| 88 | 88 | while (phys < end) { |
| 89 | 89 | const int func_id = ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_FUNC_ID; |