linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* remove set_fs for UML
@ 2021-12-15 16:56 Christoph Hellwig
  2021-12-15 16:56 ` [PATCH 1/2] x86/mtrr: remove the mtrr_bp_init stub Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-12-15 16:56 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov; +Cc: x86, linux-um, linux-kernel

Hi Richard and Anton,

this series removes address space overrides using set_fs for UML.

Diffstat:
 um/Kconfig                   |    1 -
 um/include/asm/thread_info.h |    4 ----
 um/include/asm/uaccess.h     |   21 +++++++++++++++++++--
 um/kernel/skas/uaccess.c     |   25 -------------------------
 x86/include/asm/mtrr.h       |    8 +-------
 x86/kernel/setup.c           |    7 ++++++-
 x86/um/asm/segment.h         |    8 --------
 7 files changed, 26 insertions(+), 48 deletions(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] x86/mtrr: remove the mtrr_bp_init stub
  2021-12-15 16:56 remove set_fs for UML Christoph Hellwig
@ 2021-12-15 16:56 ` Christoph Hellwig
  2021-12-22 18:56   ` [tip: x86/misc] x86/mtrr: Remove the mtrr_bp_init() stub tip-bot2 for Christoph Hellwig
  2021-12-15 16:56 ` [PATCH 2/2] um: remove set_fs Christoph Hellwig
  2021-12-21 21:05 ` remove set_fs for UML Richard Weinberger
  2 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2021-12-15 16:56 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov; +Cc: x86, linux-um, linux-kernel

Add an IS_ENABLED check in setup_arch and call pat_disable directly
if MTRRs are not supported.  This allows to remove the <asm/memtype.h>
include in <asm/mtrr.h>, which pull in lowlevel x86 headers that should
not be included for UML builds and will cause build warnings with a
futher patch.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/x86/include/asm/mtrr.h | 8 +-------
 arch/x86/kernel/setup.c     | 7 ++++++-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h
index 829df26fd7a3e..76d726074c163 100644
--- a/arch/x86/include/asm/mtrr.h
+++ b/arch/x86/include/asm/mtrr.h
@@ -24,8 +24,8 @@
 #define _ASM_X86_MTRR_H
 
 #include <uapi/asm/mtrr.h>
-#include <asm/memtype.h>
 
+void mtrr_bp_init(void);
 
 /*
  * The following functions are for use by other drivers that cannot use
@@ -43,7 +43,6 @@ extern int mtrr_del(int reg, unsigned long base, unsigned long size);
 extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
 extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
 extern void mtrr_ap_init(void);
-extern void mtrr_bp_init(void);
 extern void set_mtrr_aps_delayed_init(void);
 extern void mtrr_aps_init(void);
 extern void mtrr_bp_restore(void);
@@ -84,11 +83,6 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)
 static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
 {
 }
-static inline void mtrr_bp_init(void)
-{
-	pat_disable("PAT support disabled because CONFIG_MTRR is disabled in the kernel.");
-}
-
 #define mtrr_ap_init() do {} while (0)
 #define set_mtrr_aps_delayed_init() do {} while (0)
 #define mtrr_aps_init() do {} while (0)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 6a190c7f4d71b..2f5129bd49dc4 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -40,6 +40,7 @@
 #include <asm/kasan.h>
 #include <asm/kaslr.h>
 #include <asm/mce.h>
+#include <asm/memtype.h>
 #include <asm/mtrr.h>
 #include <asm/realmode.h>
 #include <asm/olpc_ofw.h>
@@ -979,7 +980,11 @@ void __init setup_arch(char **cmdline_p)
 	max_pfn = e820__end_of_ram_pfn();
 
 	/* update e820 for memory not covered by WB MTRRs */
-	mtrr_bp_init();
+	if (IS_ENABLED(CONFIG_MTRR))
+		mtrr_bp_init();
+	else
+		pat_disable("PAT support disabled because CONFIG_MTRR is disabled in the kernel.");
+
 	if (mtrr_trim_uncached_memory(max_pfn))
 		max_pfn = e820__end_of_ram_pfn();
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] um: remove set_fs
  2021-12-15 16:56 remove set_fs for UML Christoph Hellwig
  2021-12-15 16:56 ` [PATCH 1/2] x86/mtrr: remove the mtrr_bp_init stub Christoph Hellwig
@ 2021-12-15 16:56 ` Christoph Hellwig
  2021-12-21 21:05 ` remove set_fs for UML Richard Weinberger
  2 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-12-15 16:56 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov; +Cc: x86, linux-um, linux-kernel

Remove address space overrides using set_fs() for User Mode Linux.
Note that just like the existing kernel access case of the uaccess
routines the new nofault kernel handlers do not actually have any
exception handling.  This is probably broken, but not change to the
status quo.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/um/Kconfig                   |  1 -
 arch/um/include/asm/thread_info.h |  4 ----
 arch/um/include/asm/uaccess.h     | 21 +++++++++++++++++++--
 arch/um/kernel/skas/uaccess.c     | 25 -------------------------
 arch/x86/um/asm/segment.h         |  8 --------
 5 files changed, 19 insertions(+), 40 deletions(-)

diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index c18b45f75d41f..aafdbb6e8059e 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -21,7 +21,6 @@ config UML
 	select GENERIC_IRQ_SHOW
 	select GENERIC_CPU_DEVICES
 	select HAVE_GCC_PLUGINS
-	select SET_FS
 	select TRACE_IRQFLAGS_SUPPORT
 	select TTY # Needed for line.c
 	select HAVE_ARCH_VMAP_STACK
diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h
index 3b1cb8b3b1864..1395cbd7e340d 100644
--- a/arch/um/include/asm/thread_info.h
+++ b/arch/um/include/asm/thread_info.h
@@ -22,9 +22,6 @@ struct thread_info {
 	__u32			cpu;		/* current CPU */
 	int			preempt_count;  /* 0 => preemptable,
 						   <0 => BUG */
-	mm_segment_t		addr_limit;	/* thread address space:
-					 	   0-0xBFFFFFFF for user
-						   0-0xFFFFFFFF for kernel */
 	struct thread_info	*real_thread;    /* Points to non-IRQ stack */
 	unsigned long aux_fp_regs[FP_SIZE];	/* auxiliary fp_regs to save/restore
 						   them out-of-band */
@@ -36,7 +33,6 @@ struct thread_info {
 	.flags =		0,		\
 	.cpu =		0,			\
 	.preempt_count = INIT_PREEMPT_COUNT,	\
-	.addr_limit =	KERNEL_DS,		\
 	.real_thread = NULL,			\
 }
 
diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h
index 191ef36dd5439..17d18cfd82a51 100644
--- a/arch/um/include/asm/uaccess.h
+++ b/arch/um/include/asm/uaccess.h
@@ -8,6 +8,7 @@
 #define __UM_UACCESS_H
 
 #include <asm/elf.h>
+#include <asm/unaligned.h>
 
 #define __under_task_size(addr, size) \
 	(((unsigned long) (addr) < TASK_SIZE) && \
@@ -39,8 +40,24 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
 {
 	return __addr_range_nowrap(addr, size) &&
 		(__under_task_size(addr, size) ||
-		__access_ok_vsyscall(addr, size) ||
-		uaccess_kernel());
+		 __access_ok_vsyscall(addr, size));
 }
 
+/* no pagefaults for kernel addresses in um */
+#define HAVE_GET_KERNEL_NOFAULT 1
+
+#define __get_kernel_nofault(dst, src, type, err_label)			\
+do {									\
+	*((type *)dst) = get_unaligned((type *)(src));			\
+	if (0) /* make sure the label looks used to the compiler */	\
+		goto err_label;						\
+} while (0)
+
+#define __put_kernel_nofault(dst, src, type, err_label)			\
+do {									\
+	put_unaligned(*((type *)src), (type *)(dst));			\
+	if (0) /* make sure the label looks used to the compiler */	\
+		goto err_label;						\
+} while (0)
+
 #endif
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index a509be9110260..23775d01a2a61 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -146,11 +146,6 @@ static int copy_chunk_from_user(unsigned long from, int len, void *arg)
 
 unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n)
 {
-	if (uaccess_kernel()) {
-		memcpy(to, (__force void*)from, n);
-		return 0;
-	}
-
 	return buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to);
 }
 EXPORT_SYMBOL(raw_copy_from_user);
@@ -166,11 +161,6 @@ static int copy_chunk_to_user(unsigned long to, int len, void *arg)
 
 unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 {
-	if (uaccess_kernel()) {
-		memcpy((__force void *) to, from, n);
-		return 0;
-	}
-
 	return buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from);
 }
 EXPORT_SYMBOL(raw_copy_to_user);
@@ -196,12 +186,6 @@ long strncpy_from_user(char *dst, const char __user *src, long count)
 
 	if (!access_ok(src, 1))
 		return -EFAULT;
-
-	if (uaccess_kernel()) {
-		strncpy(dst, (__force void *) src, count);
-		return strnlen(dst, count);
-	}
-
 	n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
 		      &ptr);
 	if (n != 0)
@@ -218,11 +202,6 @@ static int clear_chunk(unsigned long addr, int len, void *unused)
 
 unsigned long __clear_user(void __user *mem, unsigned long len)
 {
-	if (uaccess_kernel()) {
-		memset((__force void*)mem, 0, len);
-		return 0;
-	}
-
 	return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL);
 }
 EXPORT_SYMBOL(__clear_user);
@@ -245,10 +224,6 @@ long strnlen_user(const char __user *str, long len)
 
 	if (!access_ok(str, 1))
 		return -EFAULT;
-
-	if (uaccess_kernel())
-		return strnlen((__force char*)str, len) + 1;
-
 	n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
 	if (n == 0)
 		return count + 1;
diff --git a/arch/x86/um/asm/segment.h b/arch/x86/um/asm/segment.h
index 453db377150d6..2ef507bc69890 100644
--- a/arch/x86/um/asm/segment.h
+++ b/arch/x86/um/asm/segment.h
@@ -8,12 +8,4 @@ extern int host_gdt_entry_tls_min;
 #define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min
 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
 
-typedef struct {
-	unsigned long seg;
-} mm_segment_t;
-
-#define MAKE_MM_SEG(s)	((mm_segment_t) { (s) })
-#define KERNEL_DS	MAKE_MM_SEG(~0UL)
-#define USER_DS		MAKE_MM_SEG(TASK_SIZE)
-
 #endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: remove set_fs for UML
  2021-12-15 16:56 remove set_fs for UML Christoph Hellwig
  2021-12-15 16:56 ` [PATCH 1/2] x86/mtrr: remove the mtrr_bp_init stub Christoph Hellwig
  2021-12-15 16:56 ` [PATCH 2/2] um: remove set_fs Christoph Hellwig
@ 2021-12-21 21:05 ` Richard Weinberger
  2021-12-22  8:17   ` hch
  2022-01-01  0:12   ` Al Viro
  2 siblings, 2 replies; 10+ messages in thread
From: Richard Weinberger @ 2021-12-21 21:05 UTC (permalink / raw)
  To: hch; +Cc: anton ivanov, x86, linux-um, linux-kernel

Christoph,

----- Ursprüngliche Mail -----
> Von: "hch" <hch@lst.de>
> An: "richard" <richard@nod.at>, "anton ivanov" <anton.ivanov@cambridgegreys.com>
> CC: "x86" <x86@kernel.org>, "linux-um" <linux-um@lists.infradead.org>, "linux-kernel" <linux-kernel@vger.kernel.org>
> Gesendet: Mittwoch, 15. Dezember 2021 17:56:10
> Betreff: remove set_fs for UML

> Hi Richard and Anton,
> 
> this series removes address space overrides using set_fs for UML.
> 
> Diffstat:
> um/Kconfig                   |    1 -
> um/include/asm/thread_info.h |    4 ----
> um/include/asm/uaccess.h     |   21 +++++++++++++++++++--
> um/kernel/skas/uaccess.c     |   25 -------------------------
> x86/include/asm/mtrr.h       |    8 +-------
> x86/kernel/setup.c           |    7 ++++++-
> x86/um/asm/segment.h         |    8 --------
>  7 files changed, 26 insertions(+), 48 deletions(-)

So far UML seems to work with these changes applied. :-)
I have applied both patches to my UML tree for now, I assume x86 maintainers are fine with
patch 1/2?

Thanks.
//richard

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: remove set_fs for UML
  2021-12-21 21:05 ` remove set_fs for UML Richard Weinberger
@ 2021-12-22  8:17   ` hch
  2021-12-22 13:55     ` Borislav Petkov
  2022-01-01  0:12   ` Al Viro
  1 sibling, 1 reply; 10+ messages in thread
From: hch @ 2021-12-22  8:17 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: hch, anton ivanov, x86, linux-um, linux-kernel

On Tue, Dec 21, 2021 at 10:05:03PM +0100, Richard Weinberger wrote:
> So far UML seems to work with these changes applied. :-)
> I have applied both patches to my UML tree for now, I assume x86 maintainers are fine with
> patch 1/2?

Looks like patch 1 needs this fixup for some configurations, where
pci.h doesn't get pulled into kvm by other means.

But we probably want an ACK from the x86 maintainers to be sure anyway..

diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c
index 0c76c45fdb686..fad546df0bbac 100644
--- a/arch/x86/kvm/mmu/spte.c
+++ b/arch/x86/kvm/mmu/spte.c
@@ -16,6 +16,7 @@
 #include "spte.h"
 
 #include <asm/e820/api.h>
+#include <asm/memtype.h>
 #include <asm/vmx.h>
 
 static bool __read_mostly enable_mmio_caching = true;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: remove set_fs for UML
  2021-12-22  8:17   ` hch
@ 2021-12-22 13:55     ` Borislav Petkov
  2021-12-22 16:55       ` Richard Weinberger
  0 siblings, 1 reply; 10+ messages in thread
From: Borislav Petkov @ 2021-12-22 13:55 UTC (permalink / raw)
  To: hch; +Cc: Richard Weinberger, anton ivanov, x86, linux-um, linux-kernel

On Wed, Dec 22, 2021 at 09:17:53AM +0100, hch wrote:
> On Tue, Dec 21, 2021 at 10:05:03PM +0100, Richard Weinberger wrote:
> > So far UML seems to work with these changes applied. :-)
> > I have applied both patches to my UML tree for now, I assume x86 maintainers are fine with
> > patch 1/2?
> 
> Looks like patch 1 needs this fixup for some configurations, where
> pci.h doesn't get pulled into kvm by other means.
> 
> But we probably want an ACK from the x86 maintainers to be sure anyway..

I don't see why not so

Acked-by: Borislav Petkov <bp@suse.de>

Should I take the first one along with this hunk below?

> diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c
> index 0c76c45fdb686..fad546df0bbac 100644
> --- a/arch/x86/kvm/mmu/spte.c
> +++ b/arch/x86/kvm/mmu/spte.c
> @@ -16,6 +16,7 @@
>  #include "spte.h"
>  
>  #include <asm/e820/api.h>
> +#include <asm/memtype.h>
>  #include <asm/vmx.h>
>  
>  static bool __read_mostly enable_mmio_caching = true;

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: remove set_fs for UML
  2021-12-22 13:55     ` Borislav Petkov
@ 2021-12-22 16:55       ` Richard Weinberger
  2021-12-22 18:54         ` Borislav Petkov
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Weinberger @ 2021-12-22 16:55 UTC (permalink / raw)
  To: bp; +Cc: hch, anton ivanov, x86, linux-um, linux-kernel

Boris,

----- Ursprüngliche Mail -----
> Von: "bp" <bp@alien8.de>
> An: "hch" <hch@lst.de>
> CC: "richard" <richard@nod.at>, "anton ivanov" <anton.ivanov@cambridgegreys.com>, "x86" <x86@kernel.org>, "linux-um"
> <linux-um@lists.infradead.org>, "linux-kernel" <linux-kernel@vger.kernel.org>
> Gesendet: Mittwoch, 22. Dezember 2021 14:55:39
> Betreff: Re: remove set_fs for UML

> On Wed, Dec 22, 2021 at 09:17:53AM +0100, hch wrote:
>> On Tue, Dec 21, 2021 at 10:05:03PM +0100, Richard Weinberger wrote:
>> > So far UML seems to work with these changes applied. :-)
>> > I have applied both patches to my UML tree for now, I assume x86 maintainers are
>> > fine with
>> > patch 1/2?
>> 
>> Looks like patch 1 needs this fixup for some configurations, where
>> pci.h doesn't get pulled into kvm by other means.
>> 
>> But we probably want an ACK from the x86 maintainers to be sure anyway..
> 
> I don't see why not so
> 
> Acked-by: Borislav Petkov <bp@suse.de>
> 
> Should I take the first one along with this hunk below?

Would be great!
When I'll drop "x86/mtrr: remove the mtrr_bp_init stub" from the UML tree.
 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: remove set_fs for UML
  2021-12-22 16:55       ` Richard Weinberger
@ 2021-12-22 18:54         ` Borislav Petkov
  0 siblings, 0 replies; 10+ messages in thread
From: Borislav Petkov @ 2021-12-22 18:54 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: hch, anton ivanov, x86, linux-um, linux-kernel

On Wed, Dec 22, 2021 at 05:55:59PM +0100, Richard Weinberger wrote:
> Would be great!
> When I'll drop "x86/mtrr: remove the mtrr_bp_init stub" from the UML tree.

Done.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip: x86/misc] x86/mtrr: Remove the mtrr_bp_init() stub
  2021-12-15 16:56 ` [PATCH 1/2] x86/mtrr: remove the mtrr_bp_init stub Christoph Hellwig
@ 2021-12-22 18:56   ` tip-bot2 for Christoph Hellwig
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Christoph Hellwig @ 2021-12-22 18:56 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Christoph Hellwig, Borislav Petkov, x86, linux-kernel

The following commit has been merged into the x86/misc branch of tip:

Commit-ID:     4d5cff69fbddbbefef2903faa48263cc5d3ca382
Gitweb:        https://git.kernel.org/tip/4d5cff69fbddbbefef2903faa48263cc5d3ca382
Author:        Christoph Hellwig <hch@lst.de>
AuthorDate:    Wed, 15 Dec 2021 17:56:11 +01:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Wed, 22 Dec 2021 19:50:26 +01:00

x86/mtrr: Remove the mtrr_bp_init() stub

Add an IS_ENABLED() check in setup_arch() and call pat_disable()
directly if MTRRs are not supported. This allows to remove the
<asm/memtype.h> include in <asm/mtrr.h>, which pull in lowlevel x86
headers that should not be included for UML builds and will cause build
warnings with a following patch.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20211215165612.554426-2-hch@lst.de
---
 arch/x86/include/asm/mtrr.h | 8 +-------
 arch/x86/kernel/setup.c     | 7 ++++++-
 arch/x86/kvm/mmu/spte.c     | 1 +
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h
index 829df26..76d7260 100644
--- a/arch/x86/include/asm/mtrr.h
+++ b/arch/x86/include/asm/mtrr.h
@@ -24,8 +24,8 @@
 #define _ASM_X86_MTRR_H
 
 #include <uapi/asm/mtrr.h>
-#include <asm/memtype.h>
 
+void mtrr_bp_init(void);
 
 /*
  * The following functions are for use by other drivers that cannot use
@@ -43,7 +43,6 @@ extern int mtrr_del(int reg, unsigned long base, unsigned long size);
 extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
 extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
 extern void mtrr_ap_init(void);
-extern void mtrr_bp_init(void);
 extern void set_mtrr_aps_delayed_init(void);
 extern void mtrr_aps_init(void);
 extern void mtrr_bp_restore(void);
@@ -84,11 +83,6 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)
 static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
 {
 }
-static inline void mtrr_bp_init(void)
-{
-	pat_disable("PAT support disabled because CONFIG_MTRR is disabled in the kernel.");
-}
-
 #define mtrr_ap_init() do {} while (0)
 #define set_mtrr_aps_delayed_init() do {} while (0)
 #define mtrr_aps_init() do {} while (0)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 6a190c7..2f5129b 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -40,6 +40,7 @@
 #include <asm/kasan.h>
 #include <asm/kaslr.h>
 #include <asm/mce.h>
+#include <asm/memtype.h>
 #include <asm/mtrr.h>
 #include <asm/realmode.h>
 #include <asm/olpc_ofw.h>
@@ -979,7 +980,11 @@ void __init setup_arch(char **cmdline_p)
 	max_pfn = e820__end_of_ram_pfn();
 
 	/* update e820 for memory not covered by WB MTRRs */
-	mtrr_bp_init();
+	if (IS_ENABLED(CONFIG_MTRR))
+		mtrr_bp_init();
+	else
+		pat_disable("PAT support disabled because CONFIG_MTRR is disabled in the kernel.");
+
 	if (mtrr_trim_uncached_memory(max_pfn))
 		max_pfn = e820__end_of_ram_pfn();
 
diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c
index 0c76c45..fad546d 100644
--- a/arch/x86/kvm/mmu/spte.c
+++ b/arch/x86/kvm/mmu/spte.c
@@ -16,6 +16,7 @@
 #include "spte.h"
 
 #include <asm/e820/api.h>
+#include <asm/memtype.h>
 #include <asm/vmx.h>
 
 static bool __read_mostly enable_mmio_caching = true;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: remove set_fs for UML
  2021-12-21 21:05 ` remove set_fs for UML Richard Weinberger
  2021-12-22  8:17   ` hch
@ 2022-01-01  0:12   ` Al Viro
  1 sibling, 0 replies; 10+ messages in thread
From: Al Viro @ 2022-01-01  0:12 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: hch, anton ivanov, x86, linux-um, linux-kernel

On Tue, Dec 21, 2021 at 10:05:03PM +0100, Richard Weinberger wrote:
> Christoph,
> 
> ----- Ursprüngliche Mail -----
> > Von: "hch" <hch@lst.de>
> > An: "richard" <richard@nod.at>, "anton ivanov" <anton.ivanov@cambridgegreys.com>
> > CC: "x86" <x86@kernel.org>, "linux-um" <linux-um@lists.infradead.org>, "linux-kernel" <linux-kernel@vger.kernel.org>
> > Gesendet: Mittwoch, 15. Dezember 2021 17:56:10
> > Betreff: remove set_fs for UML
> 
> > Hi Richard and Anton,
> > 
> > this series removes address space overrides using set_fs for UML.
> > 
> > Diffstat:
> > um/Kconfig                   |    1 -
> > um/include/asm/thread_info.h |    4 ----
> > um/include/asm/uaccess.h     |   21 +++++++++++++++++++--
> > um/kernel/skas/uaccess.c     |   25 -------------------------
> > x86/include/asm/mtrr.h       |    8 +-------
> > x86/kernel/setup.c           |    7 ++++++-
> > x86/um/asm/segment.h         |    8 --------
> >  7 files changed, 26 insertions(+), 48 deletions(-)
> 
> So far UML seems to work with these changes applied. :-)
> I have applied both patches to my UML tree for now, I assume x86 maintainers are fine with
> patch 1/2?

Hmmm...  AFAICS, the right thing to do would be to have __get_kernel_nofault
and __put_kernel_nofault in arch/x86/um/asm/something.  The question is how
to avoid duplicating the x86 implementation of those (along with the asm-goto
fun, etc.)...

But Christoph is right, it's not a new problem.  As far as I'm concerned,
that series looks fine.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-01-01  0:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 16:56 remove set_fs for UML Christoph Hellwig
2021-12-15 16:56 ` [PATCH 1/2] x86/mtrr: remove the mtrr_bp_init stub Christoph Hellwig
2021-12-22 18:56   ` [tip: x86/misc] x86/mtrr: Remove the mtrr_bp_init() stub tip-bot2 for Christoph Hellwig
2021-12-15 16:56 ` [PATCH 2/2] um: remove set_fs Christoph Hellwig
2021-12-21 21:05 ` remove set_fs for UML Richard Weinberger
2021-12-22  8:17   ` hch
2021-12-22 13:55     ` Borislav Petkov
2021-12-22 16:55       ` Richard Weinberger
2021-12-22 18:54         ` Borislav Petkov
2022-01-01  0:12   ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).