Skip to content

Commit 79b7e67

Browse files
committed
Merge tag 'for-linus-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml
Pull UML updates from Richard Weinberger: - KASAN support for x86_64 - noreboot command line option, just like qemu's -no-reboot - Various fixes and cleanups * tag 'for-linus-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml: um: include sys/types.h for size_t um: Replace to_phys() and to_virt() with less generic function names um: Add missing apply_returns() um: add "noreboot" command line option for PANIC_TIMEOUT=-1 setups um: include linux/stddef.h for __always_inline UML: add support for KASAN under x86_64 mm: Add PAGE_ALIGN_DOWN macro um: random: Don't initialise hwrng struct with zero um: remove unused mm_copy_segments um: remove unused variable um: Remove straying parenthesis um: x86: print RIP with symbol arch: um: Fix build for statically linked UML w/ constructors x86/um: Kconfig: Fix indentation um/drivers: Kconfig: Fix indentation um: Kconfig: Fix indentation
2 parents 4d5398a + af3e161 commit 79b7e67

File tree

23 files changed

+196
-53
lines changed

23 files changed

+196
-53
lines changed

arch/um/Kconfig

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ config UML
1212
select ARCH_HAS_STRNLEN_USER
1313
select ARCH_NO_PREEMPT
1414
select HAVE_ARCH_AUDITSYSCALL
15+
select HAVE_ARCH_KASAN if X86_64
16+
select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN
1517
select HAVE_ARCH_SECCOMP_FILTER
1618
select HAVE_ASM_MODVERSIONS
1719
select HAVE_UID16
@@ -82,7 +84,7 @@ config ARCH_HAS_CACHE_LINE_SIZE
8284
source "arch/$(HEADER_ARCH)/um/Kconfig"
8385

8486
config MAY_HAVE_RUNTIME_DEPS
85-
bool
87+
bool
8688

8789
config STATIC_LINK
8890
bool "Force a static link"
@@ -219,6 +221,19 @@ config UML_TIME_TRAVEL_SUPPORT
219221

220222
It is safe to say Y, but you probably don't need this.
221223

224+
config KASAN_SHADOW_OFFSET
225+
hex
226+
depends on KASAN
227+
default 0x100000000000
228+
help
229+
This is the offset at which the ~16TB of shadow memory is
230+
mapped and used by KASAN for memory debugging. This can be any
231+
address that has at least KASAN_SHADOW_SIZE (total address space divided
232+
by 8) amount of space so that the KASAN shadow memory does not conflict
233+
with anything. The default is 0x100000000000, which works even if mem is
234+
set to a large value. On low-memory systems, try 0x7fff8000, as it fits
235+
into the immediate of most instructions, improving performance.
236+
222237
endmenu
223238

224239
source "arch/um/drivers/Kconfig"

arch/um/drivers/Kconfig

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -251,37 +251,37 @@ config UML_NET_VECTOR
251251
depends on UML_NET
252252
select MAY_HAVE_RUNTIME_DEPS
253253
help
254-
This User-Mode Linux network driver uses multi-message send
255-
and receive functions. The host running the UML guest must have
256-
a linux kernel version above 3.0 and a libc version > 2.13.
257-
This driver provides tap, raw, gre and l2tpv3 network transports
258-
with up to 4 times higher network throughput than the UML network
259-
drivers.
254+
This User-Mode Linux network driver uses multi-message send
255+
and receive functions. The host running the UML guest must have
256+
a linux kernel version above 3.0 and a libc version > 2.13.
257+
This driver provides tap, raw, gre and l2tpv3 network transports
258+
with up to 4 times higher network throughput than the UML network
259+
drivers.
260260

261261
config UML_NET_VDE
262262
bool "VDE transport (obsolete)"
263263
depends on UML_NET
264264
select MAY_HAVE_RUNTIME_DEPS
265265
help
266-
This User-Mode Linux network transport allows one or more running
267-
UMLs on a single host to communicate with each other and also
268-
with the rest of the world using Virtual Distributed Ethernet,
269-
an improved fork of uml_switch.
266+
This User-Mode Linux network transport allows one or more running
267+
UMLs on a single host to communicate with each other and also
268+
with the rest of the world using Virtual Distributed Ethernet,
269+
an improved fork of uml_switch.
270270

271-
You must have libvdeplug installed in order to build the vde
272-
transport into UML.
271+
You must have libvdeplug installed in order to build the vde
272+
transport into UML.
273273

274-
To use this form of networking, you will need to run vde_switch
275-
on the host.
274+
To use this form of networking, you will need to run vde_switch
275+
on the host.
276276

277-
For more information, see <http://wiki.virtualsquare.org/>
278-
That site has a good overview of what VDE is and also examples
279-
of the UML command line to use to enable VDE networking.
277+
For more information, see <http://wiki.virtualsquare.org/>
278+
That site has a good overview of what VDE is and also examples
279+
of the UML command line to use to enable VDE networking.
280280

281-
NOTE: THIS TRANSPORT IS DEPRECATED AND WILL BE REMOVED SOON!!! Please
282-
migrate to UML_NET_VECTOR.
281+
NOTE: THIS TRANSPORT IS DEPRECATED AND WILL BE REMOVED SOON!!! Please
282+
migrate to UML_NET_VECTOR.
283283

284-
If unsure, say N.
284+
If unsure, say N.
285285

286286
config UML_NET_MCAST
287287
bool "Multicast transport (obsolete)"
@@ -311,19 +311,19 @@ config UML_NET_PCAP
311311
depends on UML_NET
312312
select MAY_HAVE_RUNTIME_DEPS
313313
help
314-
The pcap transport makes a pcap packet stream on the host look
315-
like an ethernet device inside UML. This is useful for making
316-
UML act as a network monitor for the host. You must have libcap
317-
installed in order to build the pcap transport into UML.
314+
The pcap transport makes a pcap packet stream on the host look
315+
like an ethernet device inside UML. This is useful for making
316+
UML act as a network monitor for the host. You must have libcap
317+
installed in order to build the pcap transport into UML.
318318

319319
For more information, see
320320
<http://user-mode-linux.sourceforge.net/old/networking.html> That site
321321
has examples of the UML command line to use to enable this option.
322322

323-
NOTE: THIS TRANSPORT IS DEPRECATED AND WILL BE REMOVED SOON!!! Please
324-
migrate to UML_NET_VECTOR.
323+
NOTE: THIS TRANSPORT IS DEPRECATED AND WILL BE REMOVED SOON!!! Please
324+
migrate to UML_NET_VECTOR.
325325

326-
If unsure, say N.
326+
If unsure, say N.
327327

328328
config UML_NET_SLIRP
329329
bool "SLiRP transport (obsolete)"

arch/um/drivers/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* protects against a module being loaded twice at the same time.
2929
*/
3030
static int random_fd = -1;
31-
static struct hwrng hwrng = { 0, };
31+
static struct hwrng hwrng;
3232
static DECLARE_COMPLETION(have_data);
3333

3434
static int rng_dev_read(struct hwrng *rng, void *buf, size_t max, bool block)

arch/um/include/asm/common.lds.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
}
8484
.init_array : {
8585
__init_array_start = .;
86+
*(.kasan_init)
87+
*(.init_array.*)
8688
*(.init_array)
8789
__init_array_end = .;
8890
}

arch/um/include/asm/kasan.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __ASM_UM_KASAN_H
3+
#define __ASM_UM_KASAN_H
4+
5+
#include <linux/init.h>
6+
#include <linux/const.h>
7+
8+
#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
9+
10+
/* used in kasan_mem_to_shadow to divide by 8 */
11+
#define KASAN_SHADOW_SCALE_SHIFT 3
12+
13+
#ifdef CONFIG_X86_64
14+
#define KASAN_HOST_USER_SPACE_END_ADDR 0x00007fffffffffffUL
15+
/* KASAN_SHADOW_SIZE is the size of total address space divided by 8 */
16+
#define KASAN_SHADOW_SIZE ((KASAN_HOST_USER_SPACE_END_ADDR + 1) >> \
17+
KASAN_SHADOW_SCALE_SHIFT)
18+
#else
19+
#error "KASAN_SHADOW_SIZE is not defined for this sub-architecture"
20+
#endif /* CONFIG_X86_64 */
21+
22+
#define KASAN_SHADOW_START (KASAN_SHADOW_OFFSET)
23+
#define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE)
24+
25+
#ifdef CONFIG_KASAN
26+
void kasan_init(void);
27+
void kasan_map_memory(void *start, unsigned long len);
28+
extern int kasan_um_is_ready;
29+
30+
#ifdef CONFIG_STATIC_LINK
31+
#define kasan_arch_is_ready() (kasan_um_is_ready)
32+
#endif
33+
#else
34+
static inline void kasan_init(void) { }
35+
#endif /* CONFIG_KASAN */
36+
37+
#endif /* __ASM_UM_KASAN_H */

arch/um/include/asm/processor-generic.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ static inline void release_thread(struct task_struct *task)
5959
{
6060
}
6161

62-
static inline void mm_copy_segments(struct mm_struct *from_mm,
63-
struct mm_struct *new_mm)
64-
{
65-
}
66-
6762
/*
6863
* User space process size: 3GB (default).
6964
*/

arch/um/include/asm/xor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#undef XOR_SELECT_TEMPLATE
1919
/* pick an arbitrary one - measuring isn't possible with inf-cpu */
2020
#define XOR_SELECT_TEMPLATE(x) \
21-
(time_travel_mode == TT_MODE_INFCPU ? TT_CPU_INF_XOR_DEFAULT : x))
21+
(time_travel_mode == TT_MODE_INFCPU ? TT_CPU_INF_XOR_DEFAULT : x)
2222
#endif
2323

2424
#endif

arch/um/include/shared/user.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
*/
1717
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
1818

19-
/* This is to get size_t */
19+
/* This is to get size_t and NULL */
2020
#ifndef __UM_HOST__
2121
#include <linux/types.h>
2222
#else
2323
#include <stddef.h>
24+
#include <sys/types.h>
2425
#endif
2526

2627
extern void panic(const char *fmt, ...)

arch/um/kernel/dyn.lds.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ SECTIONS
109109
be empty, which isn't pretty. */
110110
. = ALIGN(32 / 8);
111111
.preinit_array : { *(.preinit_array) }
112-
.init_array : { *(.init_array) }
112+
.init_array : {
113+
*(.kasan_init)
114+
*(.init_array.*)
115+
*(.init_array)
116+
}
113117
.fini_array : { *(.fini_array) }
114118
.data : {
115119
INIT_TASK_DATA(KERNEL_STACK_SIZE)

arch/um/kernel/mem.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@
1818
#include <kern_util.h>
1919
#include <mem_user.h>
2020
#include <os.h>
21+
#include <linux/sched/task.h>
22+
23+
#ifdef CONFIG_KASAN
24+
int kasan_um_is_ready;
25+
void kasan_init(void)
26+
{
27+
/*
28+
* kasan_map_memory will map all of the required address space and
29+
* the host machine will allocate physical memory as necessary.
30+
*/
31+
kasan_map_memory((void *)KASAN_SHADOW_START, KASAN_SHADOW_SIZE);
32+
init_task.kasan_depth = 0;
33+
kasan_um_is_ready = true;
34+
}
35+
36+
static void (*kasan_init_ptr)(void)
37+
__section(".kasan_init") __used
38+
= kasan_init;
39+
#endif
2140

2241
/* allocated in paging_init, zeroed in mem_init, and unchanged thereafter */
2342
unsigned long *empty_zero_page = NULL;

0 commit comments

Comments
 (0)