History

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

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

Linus Torvalds committed 3 months ago

Commit 0c452fb2 parents a93212b f73a8ed9 files · +85 −23Browse files

Unified · Split

9 files
  1. arch/arm64/include/asm/esr.h +1 −1
  2. arch/arm64/include/asm/fixmap.h +5 −1
  3. arch/arm64/include/asm/kprobes.h +6 −0
  4. arch/arm64/kernel/probes/kprobes.c +44 −1
  5. arch/arm64/mm/fault.c +4 −3
  6. arch/arm64/mm/hugetlbpage.c +1 −1
  7. arch/arm64/mm/mmu.c +1 −1
  8. drivers/resctrl/mpam_devices.c +22 −14
  9. drivers/virt/coco/pkvm-guest/arm-pkvm-guest.c +1 −1
arch/arm64/include/asm/esr.h+1−1
@@ -131,7 +131,7 @@ · 130 unmodified lines
131131 * Annoyingly, the negative levels for Address size faults aren't laid out
132132 * contiguously (or in the desired order)
133133 */
134−#define ESR_ELx_FSC_ADDRSZ_nL(n) ((n) == -1 ? 0x25 : 0x2C)
134+#define ESR_ELx_FSC_ADDRSZ_nL(n) ((n) == -1 ? 0x29 : 0x2C)
135135 #define ESR_ELx_FSC_ADDRSZ_L(n) ((n) < 0 ? ESR_ELx_FSC_ADDRSZ_nL(n) : \
136136 (ESR_ELx_FSC_ADDRSZ + (n)))
137137
arch/arm64/include/asm/fixmap.h+5−1
@@ -78,8 +78,12 @@ enum fixed_addresses { · 77 unmodified lines
7878 /*
7979 * Temporary boot-time mappings, used by early_ioremap(),
8080 * 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.
8185 */
82−#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE)
86+#define NR_FIX_BTMAPS ((SZ_256K / PAGE_SIZE) + 1)
8387 #define FIX_BTMAPS_SLOTS 7
8488 #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
8589
arch/arm64/include/asm/kprobes.h+6−0
@@ -26,6 +26,12 @@ · 25 unmodified lines
2626 struct prev_kprobe {
2727 struct kprobe *kp;
2828 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;
2935 };
3036
3137 /* per-cpu kprobe control block */
arch/arm64/kernel/probes/kprobes.c+44−1
@@ -174,12 +174,27 @@ static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) · 173 unmodified lines
174174 {
175175 kcb->prev_kprobe.kp = kprobe_running();
176176 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;
177185 }
178186
179187 static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb)
180188 {
181189 __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp);
182190 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;
183198 }
184199
185200 static void __kprobes set_current_kprobe(struct kprobe *p)
@@ -240,10 +255,16 @@ static int __kprobes reenter_kprobe(struct kprobe *p, · 54 unmodified lines
240255 switch (kcb->kprobe_status) {
241256 case KPROBE_HIT_SSDONE:
242257 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+ */
243265 kprobes_inc_nmissed_count(p);
244266 setup_singlestep(p, regs, kcb, 1);
245267 break;
246− case KPROBE_HIT_SS:
247268 case KPROBE_REENTER:
248269 pr_warn("Failed to recover from reentered kprobes.\n");
249270 dump_kprobe(p);
@@ -282,9 +303,31 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr) · 32 unmodified lines
282303 struct kprobe *cur = kprobe_running();
283304 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
284305
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+
285316 switch (kcb->kprobe_status) {
286317 case KPROBE_HIT_SS:
287318 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+
288331 /*
289332 * We are here because the instruction being single
290333 * stepped caused a page fault. We reset the current
arch/arm64/mm/fault.c+4−3
@@ -76,6 +76,8 @@ static void data_abort_decode(unsigned long esr) · 75 unmodified lines
7676 pr_alert(" SF = %lu, AR = %lu\n",
7777 (esr & ESR_ELx_SF) >> ESR_ELx_SF_SHIFT,
7878 (esr & ESR_ELx_AR) >> ESR_ELx_AR_SHIFT);
79+ pr_alert(" Xs = %llu\n",
80+ (iss2 & ESR_ELx_Xs_MASK) >> ESR_ELx_Xs_SHIFT);
7981 } else {
8082 pr_alert(" ISV = 0, ISS = 0x%08lx, ISS2 = 0x%08lx\n",
8183 esr & ESR_ELx_ISS_MASK, iss2);
@@ -87,11 +89,10 @@ static void data_abort_decode(unsigned long esr) · 5 unmodified lines
8789 (iss2 & ESR_ELx_TnD) >> ESR_ELx_TnD_SHIFT,
8890 (iss2 & ESR_ELx_TagAccess) >> ESR_ELx_TagAccess_SHIFT);
8991
90− pr_alert(" GCS = %ld, Overlay = %lu, DirtyBit = %lu, Xs = %llu\n",
92+ pr_alert(" GCS = %ld, Overlay = %lu, DirtyBit = %lu\n",
9193 (iss2 & ESR_ELx_GCS) >> ESR_ELx_GCS_SHIFT,
9294 (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);
9596 }
9697
9798 static void mem_abort_decode(unsigned long esr)
arch/arm64/mm/hugetlbpage.c+1−1
@@ -87,7 +87,7 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr, · 86 unmodified lines
8787 p4dp = p4d_offset(pgdp, addr);
8888 pudp = pud_offset(p4dp, addr);
8989 pmdp = pmd_offset(pudp, addr);
90− if ((pte_t *)pmdp == ptep) {
90+ if ((pte_t *)PTR_ALIGN_DOWN(pmdp, sizeof(*pmdp) * CONT_PMDS) == ptep) {
9191 *pgsize = PMD_SIZE;
9292 return CONT_PMDS;
9393 }
arch/arm64/mm/mmu.c+1−1
@@ -2194,7 +2194,7 @@ static int prevent_memory_remove_notifier(struct notifier_block *nb, · 2193 unmodified lines
21942194 }
21952195 }
21962196
2197− if (!can_unmap_without_split(pfn, arg->nr_pages))
2197+ if (!can_unmap_without_split(arg->start_pfn, arg->nr_pages))
21982198 return NOTIFY_BAD;
21992199
22002200 return NOTIFY_OK;
drivers/resctrl/mpam_devices.c+22−14
@@ -1552,12 +1552,9 @@ static u16 mpam_wa_t241_calc_min_from_max(struct mpam_props *props, · 1551 unmodified lines
15521552 static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
15531553 struct mpam_config *cfg)
15541554 {
1555− u32 pri_val = 0;
15561555 u16 cmax = MPAMCFG_CMAX_CMAX;
15571556 struct mpam_msc *msc = ris->vmsc->msc;
15581557 struct mpam_props *rprops = &ris->props;
1559− u16 dspri = GENMASK(rprops->dspri_wd, 0);
1560− u16 intpri = GENMASK(rprops->intpri_wd, 0);
15611558
15621559 mutex_lock(&msc->part_sel_lock);
15631560 __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
15831580
15841581 if (mpam_has_feature(mpam_feat_mbw_part, rprops)) {
15851582 if (mpam_has_feature(mpam_feat_mbw_part, cfg))
1586− mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops->mbw_pbm_bits);
1587− else
15881583 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);
15891586 }
15901587
15911588 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
16221619
16231620 if (mpam_has_feature(mpam_feat_intpri_part, rprops) ||
16241621 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;
16301630
1631− if (mpam_has_feature(mpam_feat_intpri_part, rprops))
16321631 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+
16341639 pri_val |= FIELD_PREP(MPAMCFG_PRI_DSPRI, dspri);
1640+ }
16351641
16361642 mpam_write_partsel_reg(msc, PRI, pri_val);
16371643 }
@@ -2606,8 +2612,10 @@ static void __destroy_component_cfg(struct mpam_component *comp) · 968 unmodified lines
26062612 msc = vmsc->msc;
26072613
26082614 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+ }
26112619 mpam_mon_sel_unlock(msc);
26122620 }
26132621 }
drivers/virt/coco/pkvm-guest/arm-pkvm-guest.c+1−1
@@ -82,8 +82,8 @@ static int mmio_guard_ioremap_hook(phys_addr_t phys, size_t size, · 81 unmodified lines
8282 if (protval != PROT_DEVICE_nGnRE && protval != PROT_DEVICE_nGnRnE)
8383 return 0;
8484
85+ end = PAGE_ALIGN(phys + size);
8586 phys = PAGE_ALIGN_DOWN(phys);
86− end = phys + PAGE_ALIGN(size);
8787
8888 while (phys < end) {
8989 const int func_id = ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_FUNC_ID;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t