Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 9aee922

Browse files
committed
Merge tag 'v6.7.9' into 6.7
This is the 6.7.9 stable release
2 parents 0fbeba2 + 2e7cdd2 commit 9aee922

159 files changed

Lines changed: 1878 additions & 813 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/arch/x86/mds.rst

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ The kernel provides a function to invoke the buffer clearing:
9595

9696
mds_clear_cpu_buffers()
9797

98+
Also macro CLEAR_CPU_BUFFERS can be used in ASM late in exit-to-user path.
99+
Other than CFLAGS.ZF, this macro doesn't clobber any registers.
100+
98101
The mitigation is invoked on kernel/userspace, hypervisor/guest and C-state
99102
(idle) transitions.
100103

@@ -138,17 +141,30 @@ Mitigation points
138141

139142
When transitioning from kernel to user space the CPU buffers are flushed
140143
on affected CPUs when the mitigation is not disabled on the kernel
141-
command line. The migitation is enabled through the static key
142-
mds_user_clear.
143-
144-
The mitigation is invoked in prepare_exit_to_usermode() which covers
145-
all but one of the kernel to user space transitions. The exception
146-
is when we return from a Non Maskable Interrupt (NMI), which is
147-
handled directly in do_nmi().
148-
149-
(The reason that NMI is special is that prepare_exit_to_usermode() can
150-
enable IRQs. In NMI context, NMIs are blocked, and we don't want to
151-
enable IRQs with NMIs blocked.)
144+
command line. The mitigation is enabled through the feature flag
145+
X86_FEATURE_CLEAR_CPU_BUF.
146+
147+
The mitigation is invoked just before transitioning to userspace after
148+
user registers are restored. This is done to minimize the window in
149+
which kernel data could be accessed after VERW e.g. via an NMI after
150+
VERW.
151+
152+
**Corner case not handled**
153+
Interrupts returning to kernel don't clear CPUs buffers since the
154+
exit-to-user path is expected to do that anyways. But, there could be
155+
a case when an NMI is generated in kernel after the exit-to-user path
156+
has cleared the buffers. This case is not handled and NMI returning to
157+
kernel don't clear CPU buffers because:
158+
159+
1. It is rare to get an NMI after VERW, but before returning to userspace.
160+
2. For an unprivileged user, there is no known way to make that NMI
161+
less rare or target it.
162+
3. It would take a large number of these precisely-timed NMIs to mount
163+
an actual attack. There's presumably not enough bandwidth.
164+
4. The NMI in question occurs after a VERW, i.e. when user state is
165+
restored and most interesting data is already scrubbed. Whats left
166+
is only the data that NMI touches, and that may or may not be of
167+
any interest.
152168

153169

154170
2. C-State transition

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 6
33
PATCHLEVEL = 7
4-
SUBLEVEL = 7
4+
SUBLEVEL = 9
55
EXTRAVERSION =
66
NAME = Hurr durr I'ma ninja sloth
77

arch/arm64/crypto/aes-neonbs-glue.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,19 @@ static int ctr_encrypt(struct skcipher_request *req)
227227
src += blocks * AES_BLOCK_SIZE;
228228
}
229229
if (nbytes && walk.nbytes == walk.total) {
230+
u8 buf[AES_BLOCK_SIZE];
231+
u8 *d = dst;
232+
233+
if (unlikely(nbytes < AES_BLOCK_SIZE))
234+
src = dst = memcpy(buf + sizeof(buf) - nbytes,
235+
src, nbytes);
236+
230237
neon_aes_ctr_encrypt(dst, src, ctx->enc, ctx->key.rounds,
231238
nbytes, walk.iv);
239+
240+
if (unlikely(nbytes < AES_BLOCK_SIZE))
241+
memcpy(d, dst, nbytes);
242+
232243
nbytes = 0;
233244
}
234245
kernel_neon_end();

arch/powerpc/include/asm/rtas.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ enum rtas_function_index {
6868
RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE,
6969
RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE2,
7070
RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW,
71-
RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOWS,
71+
RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOW,
7272
RTAS_FNIDX__IBM_SCAN_LOG_DUMP,
7373
RTAS_FNIDX__IBM_SET_DYNAMIC_INDICATOR,
7474
RTAS_FNIDX__IBM_SET_EEH_OPTION,
@@ -163,7 +163,7 @@ typedef struct {
163163
#define RTAS_FN_IBM_READ_SLOT_RESET_STATE rtas_fn_handle(RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE)
164164
#define RTAS_FN_IBM_READ_SLOT_RESET_STATE2 rtas_fn_handle(RTAS_FNIDX__IBM_READ_SLOT_RESET_STATE2)
165165
#define RTAS_FN_IBM_REMOVE_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW)
166-
#define RTAS_FN_IBM_RESET_PE_DMA_WINDOWS rtas_fn_handle(RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOWS)
166+
#define RTAS_FN_IBM_RESET_PE_DMA_WINDOW rtas_fn_handle(RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOW)
167167
#define RTAS_FN_IBM_SCAN_LOG_DUMP rtas_fn_handle(RTAS_FNIDX__IBM_SCAN_LOG_DUMP)
168168
#define RTAS_FN_IBM_SET_DYNAMIC_INDICATOR rtas_fn_handle(RTAS_FNIDX__IBM_SET_DYNAMIC_INDICATOR)
169169
#define RTAS_FN_IBM_SET_EEH_OPTION rtas_fn_handle(RTAS_FNIDX__IBM_SET_EEH_OPTION)

arch/powerpc/kernel/rtas.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,13 @@ static struct rtas_function rtas_function_table[] __ro_after_init = {
310310
[RTAS_FNIDX__IBM_REMOVE_PE_DMA_WINDOW] = {
311311
.name = "ibm,remove-pe-dma-window",
312312
},
313-
[RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOWS] = {
314-
.name = "ibm,reset-pe-dma-windows",
313+
[RTAS_FNIDX__IBM_RESET_PE_DMA_WINDOW] = {
314+
/*
315+
* Note: PAPR+ v2.13 7.3.31.4.1 spells this as
316+
* "ibm,reset-pe-dma-windows" (plural), but RTAS
317+
* implementations use the singular form in practice.
318+
*/
319+
.name = "ibm,reset-pe-dma-window",
315320
},
316321
[RTAS_FNIDX__IBM_SCAN_LOG_DUMP] = {
317322
.name = "ibm,scan-log-dump",

arch/powerpc/platforms/pseries/iommu.c

Lines changed: 105 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -574,29 +574,6 @@ static void iommu_table_setparms(struct pci_controller *phb,
574574

575575
struct iommu_table_ops iommu_table_lpar_multi_ops;
576576

577-
/*
578-
* iommu_table_setparms_lpar
579-
*
580-
* Function: On pSeries LPAR systems, return TCE table info, given a pci bus.
581-
*/
582-
static void iommu_table_setparms_lpar(struct pci_controller *phb,
583-
struct device_node *dn,
584-
struct iommu_table *tbl,
585-
struct iommu_table_group *table_group,
586-
const __be32 *dma_window)
587-
{
588-
unsigned long offset, size, liobn;
589-
590-
of_parse_dma_window(dn, dma_window, &liobn, &offset, &size);
591-
592-
iommu_table_setparms_common(tbl, phb->bus->number, liobn, offset, size, IOMMU_PAGE_SHIFT_4K, NULL,
593-
&iommu_table_lpar_multi_ops);
594-
595-
596-
table_group->tce32_start = offset;
597-
table_group->tce32_size = size;
598-
}
599-
600577
struct iommu_table_ops iommu_table_pseries_ops = {
601578
.set = tce_build_pSeries,
602579
.clear = tce_free_pSeries,
@@ -724,44 +701,92 @@ struct iommu_table_ops iommu_table_lpar_multi_ops = {
724701
* dynamic 64bit DMA window, walking up the device tree.
725702
*/
726703
static struct device_node *pci_dma_find(struct device_node *dn,
727-
const __be32 **dma_window)
704+
struct dynamic_dma_window_prop *prop)
728705
{
729-
const __be32 *dw = NULL;
706+
const __be32 *default_prop = NULL;
707+
const __be32 *ddw_prop = NULL;
708+
struct device_node *rdn = NULL;
709+
bool default_win = false, ddw_win = false;
730710

731711
for ( ; dn && PCI_DN(dn); dn = dn->parent) {
732-
dw = of_get_property(dn, "ibm,dma-window", NULL);
733-
if (dw) {
734-
if (dma_window)
735-
*dma_window = dw;
736-
return dn;
712+
default_prop = of_get_property(dn, "ibm,dma-window", NULL);
713+
if (default_prop) {
714+
rdn = dn;
715+
default_win = true;
716+
}
717+
ddw_prop = of_get_property(dn, DIRECT64_PROPNAME, NULL);
718+
if (ddw_prop) {
719+
rdn = dn;
720+
ddw_win = true;
721+
break;
722+
}
723+
ddw_prop = of_get_property(dn, DMA64_PROPNAME, NULL);
724+
if (ddw_prop) {
725+
rdn = dn;
726+
ddw_win = true;
727+
break;
737728
}
738-
dw = of_get_property(dn, DIRECT64_PROPNAME, NULL);
739-
if (dw)
740-
return dn;
741-
dw = of_get_property(dn, DMA64_PROPNAME, NULL);
742-
if (dw)
743-
return dn;
729+
730+
/* At least found default window, which is the case for normal boot */
731+
if (default_win)
732+
break;
744733
}
745734

746-
return NULL;
735+
/* For PCI devices there will always be a DMA window, either on the device
736+
* or parent bus
737+
*/
738+
WARN_ON(!(default_win | ddw_win));
739+
740+
/* caller doesn't want to get DMA window property */
741+
if (!prop)
742+
return rdn;
743+
744+
/* parse DMA window property. During normal system boot, only default
745+
* DMA window is passed in OF. But, for kdump, a dedicated adapter might
746+
* have both default and DDW in FDT. In this scenario, DDW takes precedence
747+
* over default window.
748+
*/
749+
if (ddw_win) {
750+
struct dynamic_dma_window_prop *p;
751+
752+
p = (struct dynamic_dma_window_prop *)ddw_prop;
753+
prop->liobn = p->liobn;
754+
prop->dma_base = p->dma_base;
755+
prop->tce_shift = p->tce_shift;
756+
prop->window_shift = p->window_shift;
757+
} else if (default_win) {
758+
unsigned long offset, size, liobn;
759+
760+
of_parse_dma_window(rdn, default_prop, &liobn, &offset, &size);
761+
762+
prop->liobn = cpu_to_be32((u32)liobn);
763+
prop->dma_base = cpu_to_be64(offset);
764+
prop->tce_shift = cpu_to_be32(IOMMU_PAGE_SHIFT_4K);
765+
prop->window_shift = cpu_to_be32(order_base_2(size));
766+
}
767+
768+
return rdn;
747769
}
748770

749771
static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
750772
{
751773
struct iommu_table *tbl;
752774
struct device_node *dn, *pdn;
753775
struct pci_dn *ppci;
754-
const __be32 *dma_window = NULL;
776+
struct dynamic_dma_window_prop prop;
755777

756778
dn = pci_bus_to_OF_node(bus);
757779

758780
pr_debug("pci_dma_bus_setup_pSeriesLP: setting up bus %pOF\n",
759781
dn);
760782

761-
pdn = pci_dma_find(dn, &dma_window);
783+
pdn = pci_dma_find(dn, &prop);
762784

763-
if (dma_window == NULL)
764-
pr_debug(" no ibm,dma-window property !\n");
785+
/* In PPC architecture, there will always be DMA window on bus or one of the
786+
* parent bus. During reboot, there will be ibm,dma-window property to
787+
* define DMA window. For kdump, there will at least be default window or DDW
788+
* or both.
789+
*/
765790

766791
ppci = PCI_DN(pdn);
767792

@@ -771,13 +796,24 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
771796
if (!ppci->table_group) {
772797
ppci->table_group = iommu_pseries_alloc_group(ppci->phb->node);
773798
tbl = ppci->table_group->tables[0];
774-
if (dma_window) {
775-
iommu_table_setparms_lpar(ppci->phb, pdn, tbl,
776-
ppci->table_group, dma_window);
777799

778-
if (!iommu_init_table(tbl, ppci->phb->node, 0, 0))
779-
panic("Failed to initialize iommu table");
780-
}
800+
iommu_table_setparms_common(tbl, ppci->phb->bus->number,
801+
be32_to_cpu(prop.liobn),
802+
be64_to_cpu(prop.dma_base),
803+
1ULL << be32_to_cpu(prop.window_shift),
804+
be32_to_cpu(prop.tce_shift), NULL,
805+
&iommu_table_lpar_multi_ops);
806+
807+
/* Only for normal boot with default window. Doesn't matter even
808+
* if we set these with DDW which is 64bit during kdump, since
809+
* these will not be used during kdump.
810+
*/
811+
ppci->table_group->tce32_start = be64_to_cpu(prop.dma_base);
812+
ppci->table_group->tce32_size = 1 << be32_to_cpu(prop.window_shift);
813+
814+
if (!iommu_init_table(tbl, ppci->phb->node, 0, 0))
815+
panic("Failed to initialize iommu table");
816+
781817
iommu_register_group(ppci->table_group,
782818
pci_domain_nr(bus), 0);
783819
pr_debug(" created table: %p\n", ppci->table_group);
@@ -968,6 +1004,12 @@ static void find_existing_ddw_windows_named(const char *name)
9681004
continue;
9691005
}
9701006

1007+
/* If at the time of system initialization, there are DDWs in OF,
1008+
* it means this is during kexec. DDW could be direct or dynamic.
1009+
* We will just mark DDWs as "dynamic" since this is kdump path,
1010+
* no need to worry about perforance. ddw_list_new_entry() will
1011+
* set window->direct = false.
1012+
*/
9711013
window = ddw_list_new_entry(pdn, dma64);
9721014
if (!window) {
9731015
of_node_put(pdn);
@@ -1524,8 +1566,8 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
15241566
{
15251567
struct device_node *pdn, *dn;
15261568
struct iommu_table *tbl;
1527-
const __be32 *dma_window = NULL;
15281569
struct pci_dn *pci;
1570+
struct dynamic_dma_window_prop prop;
15291571

15301572
pr_debug("pci_dma_dev_setup_pSeriesLP: %s\n", pci_name(dev));
15311573

@@ -1538,7 +1580,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
15381580
dn = pci_device_to_OF_node(dev);
15391581
pr_debug(" node is %pOF\n", dn);
15401582

1541-
pdn = pci_dma_find(dn, &dma_window);
1583+
pdn = pci_dma_find(dn, &prop);
15421584
if (!pdn || !PCI_DN(pdn)) {
15431585
printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: "
15441586
"no DMA window found for pci dev=%s dn=%pOF\n",
@@ -1551,8 +1593,20 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
15511593
if (!pci->table_group) {
15521594
pci->table_group = iommu_pseries_alloc_group(pci->phb->node);
15531595
tbl = pci->table_group->tables[0];
1554-
iommu_table_setparms_lpar(pci->phb, pdn, tbl,
1555-
pci->table_group, dma_window);
1596+
1597+
iommu_table_setparms_common(tbl, pci->phb->bus->number,
1598+
be32_to_cpu(prop.liobn),
1599+
be64_to_cpu(prop.dma_base),
1600+
1ULL << be32_to_cpu(prop.window_shift),
1601+
be32_to_cpu(prop.tce_shift), NULL,
1602+
&iommu_table_lpar_multi_ops);
1603+
1604+
/* Only for normal boot with default window. Doesn't matter even
1605+
* if we set these with DDW which is 64bit during kdump, since
1606+
* these will not be used during kdump.
1607+
*/
1608+
pci->table_group->tce32_start = be64_to_cpu(prop.dma_base);
1609+
pci->table_group->tce32_size = 1 << be32_to_cpu(prop.window_shift);
15561610

15571611
iommu_init_table(tbl, pci->phb->node, 0, 0);
15581612
iommu_register_group(pci->table_group,

arch/riscv/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ config AS_HAS_OPTION_ARCH
294294
# https://reviews.llvm.org/D123515
295295
def_bool y
296296
depends on $(as-instr, .option arch$(comma) +m)
297-
depends on !$(as-instr, .option arch$(comma) -i)
298297

299298
source "arch/riscv/Kconfig.socs"
300299
source "arch/riscv/Kconfig.errata"

arch/riscv/include/asm/csr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@
415415
# define CSR_STATUS CSR_MSTATUS
416416
# define CSR_IE CSR_MIE
417417
# define CSR_TVEC CSR_MTVEC
418+
# define CSR_ENVCFG CSR_MENVCFG
418419
# define CSR_SCRATCH CSR_MSCRATCH
419420
# define CSR_EPC CSR_MEPC
420421
# define CSR_CAUSE CSR_MCAUSE
@@ -439,6 +440,7 @@
439440
# define CSR_STATUS CSR_SSTATUS
440441
# define CSR_IE CSR_SIE
441442
# define CSR_TVEC CSR_STVEC
443+
# define CSR_ENVCFG CSR_SENVCFG
442444
# define CSR_SCRATCH CSR_SSCRATCH
443445
# define CSR_EPC CSR_SEPC
444446
# define CSR_CAUSE CSR_SCAUSE

arch/riscv/include/asm/ftrace.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
#define ARCH_SUPPORTS_FTRACE_OPS 1
2727
#ifndef __ASSEMBLY__
28+
29+
extern void *return_address(unsigned int level);
30+
31+
#define ftrace_return_address(n) return_address(n)
32+
2833
void MCOUNT_NAME(void);
2934
static inline unsigned long ftrace_call_adjust(unsigned long addr)
3035
{

arch/riscv/include/asm/hugetlb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ static inline void arch_clear_hugepage_flags(struct page *page)
1111
}
1212
#define arch_clear_hugepage_flags arch_clear_hugepage_flags
1313

14+
#ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
1415
bool arch_hugetlb_migration_supported(struct hstate *h);
1516
#define arch_hugetlb_migration_supported arch_hugetlb_migration_supported
17+
#endif
1618

1719
#ifdef CONFIG_RISCV_ISA_SVNAPOT
1820
#define __HAVE_ARCH_HUGE_PTE_CLEAR

0 commit comments

Comments
 (0)