Skip to content

Commit 69e858e

Browse files
committed
Merge tag 'uml-for-linus-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux
Pull UML updates from Richard Weinberger: - hostfs: Convert to writepages - many cleanups: removal of dead macros, missing __init * tag 'uml-for-linus-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux: um: Remove unused asm/archparam.h header um: Include missing headers in asm/pgtable.h hostfs: Convert to writepages um: rtc: use RTC time when calculating the alarm um: Remove unused user_context function um: Remove unused THREAD_NAME_LEN macro um: Remove unused PGD_BOUND macro um: Mark setup_env_path as __init um: Mark install_fatal_handler as __init um: Mark set_stklim as __init um: Mark get_top_address as __init um: Mark parse_cache_line as __init um: Mark parse_host_cpu_flags as __init um: Count iomem_size only once in physmem calculation um: Remove obsolete fixmap support um: Remove unused MODULES_LEN macro
2 parents 350130a + 2d2b61a commit 69e858e

File tree

10 files changed

+46
-143
lines changed

10 files changed

+46
-143
lines changed

arch/um/drivers/rtc_kern.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ static int uml_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
5151

5252
static int uml_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
5353
{
54+
struct timespec64 ts;
5455
unsigned long long secs;
5556

5657
if (!enable && !uml_rtc_alarm_enabled)
5758
return 0;
5859

5960
uml_rtc_alarm_enabled = enable;
6061

61-
secs = uml_rtc_alarm_time - ktime_get_real_seconds();
62+
read_persistent_clock64(&ts);
63+
secs = uml_rtc_alarm_time - ts.tv_sec;
6264

6365
if (time_travel_mode == TT_MODE_OFF) {
6466
if (!enable) {
@@ -73,7 +75,8 @@ static int uml_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
7375

7476
if (enable)
7577
time_travel_add_event_rel(&uml_rtc_alarm_event,
76-
secs * NSEC_PER_SEC);
78+
secs * NSEC_PER_SEC -
79+
ts.tv_nsec);
7780
}
7881

7982
return 0;

arch/um/include/asm/fixmap.h

-56
This file was deleted.

arch/um/include/asm/pgtable.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#ifndef __UM_PGTABLE_H
99
#define __UM_PGTABLE_H
1010

11-
#include <asm/fixmap.h>
11+
#include <asm/page.h>
12+
#include <linux/mm_types.h>
1213

1314
#define _PAGE_PRESENT 0x001
1415
#define _PAGE_NEEDSYNC 0x002
@@ -48,11 +49,9 @@ extern unsigned long end_iomem;
4849

4950
#define VMALLOC_OFFSET (__va_space)
5051
#define VMALLOC_START ((end_iomem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
51-
#define PKMAP_BASE ((FIXADDR_START - LAST_PKMAP * PAGE_SIZE) & PMD_MASK)
52-
#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
52+
#define VMALLOC_END (TASK_SIZE-2*PAGE_SIZE)
5353
#define MODULES_VADDR VMALLOC_START
5454
#define MODULES_END VMALLOC_END
55-
#define MODULES_LEN (MODULES_VADDR - MODULES_END)
5655

5756
#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
5857
#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)

arch/um/kernel/mem.c

+4-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <linux/mm.h>
1010
#include <linux/swap.h>
1111
#include <linux/slab.h>
12-
#include <asm/fixmap.h>
1312
#include <asm/page.h>
1413
#include <asm/pgalloc.h>
1514
#include <as-layout.h>
@@ -74,6 +73,7 @@ void __init mem_init(void)
7473
kmalloc_ok = 1;
7574
}
7675

76+
#if IS_ENABLED(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA)
7777
/*
7878
* Create a page table and place a pointer to it in a middle page
7979
* directory entry.
@@ -152,7 +152,6 @@ static void __init fixrange_init(unsigned long start, unsigned long end,
152152

153153
static void __init fixaddr_user_init( void)
154154
{
155-
#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
156155
long size = FIXADDR_USER_END - FIXADDR_USER_START;
157156
pte_t *pte;
158157
phys_t p;
@@ -174,13 +173,12 @@ static void __init fixaddr_user_init( void)
174173
pte = virt_to_kpte(vaddr);
175174
pte_set_val(*pte, p, PAGE_READONLY);
176175
}
177-
#endif
178176
}
177+
#endif
179178

180179
void __init paging_init(void)
181180
{
182181
unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
183-
unsigned long vaddr;
184182

185183
empty_zero_page = (unsigned long *) memblock_alloc_low(PAGE_SIZE,
186184
PAGE_SIZE);
@@ -191,14 +189,9 @@ void __init paging_init(void)
191189
max_zone_pfn[ZONE_NORMAL] = end_iomem >> PAGE_SHIFT;
192190
free_area_init(max_zone_pfn);
193191

194-
/*
195-
* Fixed mappings, only the page table structure has to be
196-
* created - mappings will be set by set_fixmap():
197-
*/
198-
vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
199-
fixrange_init(vaddr, FIXADDR_TOP, swapper_pg_dir);
200-
192+
#if IS_ENABLED(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA)
201193
fixaddr_user_init();
194+
#endif
202195
}
203196

204197
/*

arch/um/kernel/process.c

-8
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,6 @@ int __uml_cant_sleep(void) {
213213
/* Is in_interrupt() really needed? */
214214
}
215215

216-
int user_context(unsigned long sp)
217-
{
218-
unsigned long stack;
219-
220-
stack = sp & (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER);
221-
return stack != (unsigned long) current_thread_info();
222-
}
223-
224216
extern exitcall_t __uml_exitcall_begin, __uml_exitcall_end;
225217

226218
void do_uml_exitcalls(void)

arch/um/kernel/um_arch.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,16 @@ EXPORT_SYMBOL(end_iomem);
264264

265265
#define MIN_VMALLOC (32 * 1024 * 1024)
266266

267-
static void parse_host_cpu_flags(char *line)
267+
static void __init parse_host_cpu_flags(char *line)
268268
{
269269
int i;
270270
for (i = 0; i < 32*NCAPINTS; i++) {
271271
if ((x86_cap_flags[i] != NULL) && strstr(line, x86_cap_flags[i]))
272272
set_cpu_cap(&boot_cpu_data, i);
273273
}
274274
}
275-
static void parse_cache_line(char *line)
275+
276+
static void __init parse_cache_line(char *line)
276277
{
277278
long res;
278279
char *to_parse = strstr(line, ":");
@@ -288,7 +289,7 @@ static void parse_cache_line(char *line)
288289
}
289290
}
290291

291-
static unsigned long get_top_address(char **envp)
292+
static unsigned long __init get_top_address(char **envp)
292293
{
293294
unsigned long top_addr = (unsigned long) &top_addr;
294295
int i;
@@ -376,9 +377,8 @@ int __init linux_main(int argc, char **argv, char **envp)
376377
iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
377378

378379
max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
379-
380-
if (physmem_size + iomem_size > max_physmem) {
381-
physmem_size = max_physmem - iomem_size;
380+
if (physmem_size > max_physmem) {
381+
physmem_size = max_physmem;
382382
os_info("Physical memory size shrunk to %llu bytes\n",
383383
physmem_size);
384384
}

arch/um/os-Linux/main.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
#include <um_malloc.h>
2020
#include "internal.h"
2121

22-
#define PGD_BOUND (4 * 1024 * 1024)
2322
#define STACKSIZE (8 * 1024 * 1024)
24-
#define THREAD_NAME_LEN (256)
2523

2624
long elf_aux_hwcap;
2725

28-
static void set_stklim(void)
26+
static void __init set_stklim(void)
2927
{
3028
struct rlimit lim;
3129

@@ -48,7 +46,7 @@ static void last_ditch_exit(int sig)
4846
exit(1);
4947
}
5048

51-
static void install_fatal_handler(int sig)
49+
static void __init install_fatal_handler(int sig)
5250
{
5351
struct sigaction action;
5452

@@ -73,7 +71,7 @@ static void install_fatal_handler(int sig)
7371

7472
#define UML_LIB_PATH ":" OS_LIB_PATH "/uml"
7573

76-
static void setup_env_path(void)
74+
static void __init setup_env_path(void)
7775
{
7876
char *new_path = NULL;
7977
char *old_path = NULL;

arch/x86/um/asm/archparam.h

-20
This file was deleted.

arch/x86/um/shared/sysdep/ptrace.h

-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ struct uml_pt_regs {
7474
#define UPT_FAULTINFO(r) (&(r)->faultinfo)
7575
#define UPT_IS_USER(r) ((r)->is_user)
7676

77-
extern int user_context(unsigned long sp);
78-
7977
extern int arch_init_registers(int pid);
8078

8179
#endif /* __SYSDEP_X86_PTRACE_H */

fs/hostfs/hostfs_kern.c

+25-29
Original file line numberDiff line numberDiff line change
@@ -410,38 +410,33 @@ static const struct file_operations hostfs_dir_fops = {
410410
.fsync = hostfs_fsync,
411411
};
412412

413-
static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
413+
static int hostfs_writepages(struct address_space *mapping,
414+
struct writeback_control *wbc)
414415
{
415-
struct address_space *mapping = page->mapping;
416416
struct inode *inode = mapping->host;
417-
char *buffer;
418-
loff_t base = page_offset(page);
419-
int count = PAGE_SIZE;
420-
int end_index = inode->i_size >> PAGE_SHIFT;
421-
int err;
422-
423-
if (page->index >= end_index)
424-
count = inode->i_size & (PAGE_SIZE-1);
425-
426-
buffer = kmap_local_page(page);
427-
428-
err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
429-
if (err != count) {
430-
if (err >= 0)
431-
err = -EIO;
432-
mapping_set_error(mapping, err);
433-
goto out;
417+
struct folio *folio = NULL;
418+
loff_t i_size = i_size_read(inode);
419+
int err = 0;
420+
421+
while ((folio = writeback_iter(mapping, wbc, folio, &err))) {
422+
loff_t pos = folio_pos(folio);
423+
size_t count = folio_size(folio);
424+
char *buffer;
425+
int ret;
426+
427+
if (count > i_size - pos)
428+
count = i_size - pos;
429+
430+
buffer = kmap_local_folio(folio, 0);
431+
ret = write_file(HOSTFS_I(inode)->fd, &pos, buffer, count);
432+
kunmap_local(buffer);
433+
folio_unlock(folio);
434+
if (ret != count) {
435+
err = ret < 0 ? ret : -EIO;
436+
mapping_set_error(mapping, err);
437+
}
434438
}
435439

436-
if (base > inode->i_size)
437-
inode->i_size = base;
438-
439-
err = 0;
440-
441-
out:
442-
kunmap_local(buffer);
443-
unlock_page(page);
444-
445440
return err;
446441
}
447442

@@ -506,11 +501,12 @@ static int hostfs_write_end(struct file *file, struct address_space *mapping,
506501
}
507502

508503
static const struct address_space_operations hostfs_aops = {
509-
.writepage = hostfs_writepage,
504+
.writepages = hostfs_writepages,
510505
.read_folio = hostfs_read_folio,
511506
.dirty_folio = filemap_dirty_folio,
512507
.write_begin = hostfs_write_begin,
513508
.write_end = hostfs_write_end,
509+
.migrate_folio = filemap_migrate_folio,
514510
};
515511

516512
static int hostfs_inode_update(struct inode *ino, const struct hostfs_stat *st)

0 commit comments

Comments
 (0)