qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL v2 00/39] tcg and linux-user patch queue
@ 2024-02-24  1:05 Richard Henderson
  2024-02-24  1:05 ` [PULL v2 31/39] *-user: Deprecate and disable -p pagesize Richard Henderson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Richard Henderson @ 2024-02-24  1:05 UTC (permalink / raw)
  To: qemu-devel

v2: Fix bsd-user build errors.


r~


The following changes since commit 3d54cbf269d63ff1d500b35b2bcf4565ff8ad485:

  Merge tag 'hw-misc-20240222' of https://github.com/philmd/qemu into staging (2024-02-22 15:44:29 +0000)

are available in the Git repository at:

  https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240222-2

for you to fetch changes up to fcc6ad372f56d3f47b6d5457a904916b48b9e114:

  linux-user: Remove pgb_dynamic alignment assertion (2024-02-23 15:07:03 -0800)

----------------------------------------------------------------
tcg/aarch64: Apple does not align __int128_t in even registers
accel/tcg: Fixes for page tables in mmio memory
linux-user: Remove qemu_host_page_{size,mask}, HOST_PAGE_ALIGN
migration: Remove qemu_host_page_size
hw/tpm: Remove qemu_host_page_size
softmmu: Remove qemu_host_page_{size,mask}, HOST_PAGE_ALIGN
linux-user: Split and reorganize target_mmap.
*-user: Deprecate and disable -p pagesize
linux-user: Allow TARGET_PAGE_BITS_VARY
target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only
target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only
target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only
linux-user: Remove pgb_dynamic alignment assertion

----------------------------------------------------------------
Jonathan Cameron (1):
      tcg: Avoid double lock if page tables happen to be in mmio memory.

Peter Maydell (1):
      accel/tcg: Set can_do_io at at start of lookup_tb_ptr helper

Richard Henderson (37):
      tcg/aarch64: Apple does not align __int128_t in even registers
      accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect
      linux-user: Adjust SVr4 NULL page mapping
      linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base
      linux-user: Remove qemu_host_page_size from create_elf_tables
      linux-user/hppa: Simplify init_guest_commpage
      linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage
      linux-user/arm: Remove qemu_host_page_size from init_guest_commpage
      linux-user: Remove qemu_host_page_{size, mask} from mmap.c
      linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c
      linux-user: Remove HOST_PAGE_ALIGN from mmap.c
      migration: Remove qemu_host_page_size
      hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init
      softmmu/physmem: Remove qemu_host_page_size
      softmmu/physmem: Remove HOST_PAGE_ALIGN
      linux-user: Remove qemu_host_page_size from main
      linux-user: Split out target_mmap__locked
      linux-user: Move some mmap checks outside the lock
      linux-user: Fix sub-host-page mmap
      linux-user: Split out mmap_end
      linux-user: Do early mmap placement only for reserved_va
      linux-user: Split out do_munmap
      linux-user: Use do_munmap for target_mmap failure
      linux-user: Split out mmap_h_eq_g
      linux-user: Split out mmap_h_lt_g
      linux-user: Split out mmap_h_gt_g
      tests/tcg: Remove run-test-mmap-*
      tests/tcg: Extend file in linux-madvise.c
      *-user: Deprecate and disable -p pagesize
      cpu: Remove page_size_init
      accel/tcg: Disconnect TargetPageDataNode from page size
      linux-user: Allow TARGET_PAGE_BITS_VARY
      target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only
      linux-user: Bound mmap_min_addr by host page size
      target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only
      target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only
      linux-user: Remove pgb_dynamic alignment assertion

 docs/about/deprecated.rst                 |  10 +
 docs/user/main.rst                        |   3 -
 bsd-user/qemu.h                           |   7 +
 include/exec/cpu-common.h                 |   7 -
 include/hw/core/cpu.h                     |   2 -
 target/alpha/cpu-param.h                  |  16 +-
 target/arm/cpu-param.h                    |   6 +-
 target/ppc/cpu-param.h                    |   9 +-
 tcg/aarch64/tcg-target.h                  |   6 +-
 accel/tcg/cpu-exec.c                      |   8 +
 accel/tcg/cputlb.c                        |  34 +-
 accel/tcg/translate-all.c                 |   1 -
 accel/tcg/user-exec.c                     |  31 +-
 bsd-user/main.c                           |  23 +-
 cpu-target.c                              |  16 -
 hw/tpm/tpm_ppi.c                          |   6 +-
 linux-user/elfload.c                      |  68 +--
 linux-user/main.c                         |  34 +-
 linux-user/mmap.c                         | 767 ++++++++++++++++++------------
 migration/ram.c                           |  22 +-
 system/physmem.c                          |  17 +-
 system/vl.c                               |   1 -
 target/arm/cpu.c                          |  51 +-
 tests/tcg/multiarch/linux/linux-madvise.c |   2 +
 tests/tcg/alpha/Makefile.target           |   3 -
 tests/tcg/arm/Makefile.target             |   3 -
 tests/tcg/hppa/Makefile.target            |   3 -
 tests/tcg/i386/Makefile.target            |   3 -
 tests/tcg/m68k/Makefile.target            |   3 -
 tests/tcg/multiarch/Makefile.target       |   9 -
 tests/tcg/ppc/Makefile.target             |  12 -
 tests/tcg/sh4/Makefile.target             |   3 -
 tests/tcg/sparc64/Makefile.target         |   6 -
 33 files changed, 701 insertions(+), 491 deletions(-)
 delete mode 100644 tests/tcg/ppc/Makefile.target
 delete mode 100644 tests/tcg/sparc64/Makefile.target


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

* [PULL v2 31/39] *-user: Deprecate and disable -p pagesize
  2024-02-24  1:05 [PULL v2 00/39] tcg and linux-user patch queue Richard Henderson
@ 2024-02-24  1:05 ` Richard Henderson
  2024-02-24  1:05 ` [PULL v2 32/39] cpu: Remove page_size_init Richard Henderson
  2024-02-24 16:15 ` [PULL v2 00/39] tcg and linux-user patch queue Peter Maydell
  2 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2024-02-24  1:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Warner Losh, Philippe Mathieu-Daudé, Helge Deller

This option controls the host page size.  From the mis-usage in
our own testsuite, this is easily confused with guest page size.

The only thing that occurs when changing the host page size is
that stuff breaks, because one cannot actually change the host
page size.  Therefore reject all but the no-op setting as part
of the deprecation process.

Reviewed-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Helge Deller <deller@gmx.de>
Message-Id: <20240102015808.132373-27-richard.henderson@linaro.org>
---
 docs/about/deprecated.rst | 10 ++++++++++
 docs/user/main.rst        |  3 ---
 bsd-user/main.c           | 11 ++++++-----
 linux-user/main.c         | 12 ++++++------
 4 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 5a2305ccd6..3074303b9c 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -63,6 +63,16 @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
 However, short-form booleans are deprecated and full explicit ``arg_name=on``
 form is preferred.
 
+User-mode emulator command line arguments
+-----------------------------------------
+
+``-p`` (since 9.0)
+''''''''''''''''''
+
+The ``-p`` option pretends to control the host page size.  However,
+it is not possible to change the host page size, and using the
+option only causes failures.
+
 QEMU Machine Protocol (QMP) commands
 ------------------------------------
 
diff --git a/docs/user/main.rst b/docs/user/main.rst
index 7e7ad07409..d5fbb78d3c 100644
--- a/docs/user/main.rst
+++ b/docs/user/main.rst
@@ -87,9 +87,6 @@ Debug options:
    Activate logging of the specified items (use '-d help' for a list of
    log items)
 
-``-p pagesize``
-   Act as if the host page size was 'pagesize' bytes
-
 ``-g port``
    Wait gdb connection to port
 
diff --git a/bsd-user/main.c b/bsd-user/main.c
index e5efb7b845..6ab3efd6c0 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -364,11 +364,12 @@ int main(int argc, char **argv)
         } else if (!strcmp(r, "L")) {
             interp_prefix = argv[optind++];
         } else if (!strcmp(r, "p")) {
-            qemu_host_page_size = atoi(argv[optind++]);
-            if (qemu_host_page_size == 0 ||
-                (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
-                fprintf(stderr, "page size must be a power of two\n");
-                exit(1);
+            unsigned size, want = qemu_real_host_page_size();
+
+            r = argv[optind++];
+            if (qemu_strtoui(r, NULL, 10, &size) || size != want) {
+                warn_report("Deprecated page size option cannot "
+                            "change host page size (%u)", want);
             }
         } else if (!strcmp(r, "g")) {
             gdbstub = g_strdup(argv[optind++]);
diff --git a/linux-user/main.c b/linux-user/main.c
index e540acb84a..bad03f06d3 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -332,11 +332,11 @@ static void handle_arg_ld_prefix(const char *arg)
 
 static void handle_arg_pagesize(const char *arg)
 {
-    qemu_host_page_size = atoi(arg);
-    if (qemu_host_page_size == 0 ||
-        (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
-        fprintf(stderr, "page size must be a power of two\n");
-        exit(EXIT_FAILURE);
+    unsigned size, want = qemu_real_host_page_size();
+
+    if (qemu_strtoui(arg, NULL, 10, &size) || size != want) {
+        warn_report("Deprecated page size option cannot "
+                    "change host page size (%u)", want);
     }
 }
 
@@ -496,7 +496,7 @@ static const struct qemu_argument arg_table[] = {
     {"D",          "QEMU_LOG_FILENAME", true, handle_arg_log_filename,
      "logfile",     "write logs to 'logfile' (default stderr)"},
     {"p",          "QEMU_PAGESIZE",    true,  handle_arg_pagesize,
-     "pagesize",   "set the host page size to 'pagesize'"},
+     "pagesize",   "deprecated change to host page size"},
     {"one-insn-per-tb",
                    "QEMU_ONE_INSN_PER_TB",  false, handle_arg_one_insn_per_tb,
      "",           "run with one guest instruction per emulated TB"},
-- 
2.34.1



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

* [PULL v2 32/39] cpu: Remove page_size_init
  2024-02-24  1:05 [PULL v2 00/39] tcg and linux-user patch queue Richard Henderson
  2024-02-24  1:05 ` [PULL v2 31/39] *-user: Deprecate and disable -p pagesize Richard Henderson
@ 2024-02-24  1:05 ` Richard Henderson
  2024-02-24 16:15 ` [PULL v2 00/39] tcg and linux-user patch queue Peter Maydell
  2 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2024-02-24  1:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Warner Losh, Philippe Mathieu-Daudé, Ilya Leoshkevich,
	Helge Deller

Move qemu_host_page_{size,mask} and HOST_PAGE_ALIGN into bsd-user.
It should be removed from bsd-user as well, but defer that cleanup.

Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Helge Deller <deller@gmx.de>
Message-Id: <20240102015808.132373-28-richard.henderson@linaro.org>
---
 bsd-user/qemu.h           |  7 +++++++
 include/exec/cpu-common.h |  7 -------
 include/hw/core/cpu.h     |  2 --
 accel/tcg/translate-all.c |  1 -
 bsd-user/main.c           | 12 ++++++++++++
 cpu-target.c              | 16 ----------------
 system/vl.c               |  1 -
 7 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index dc842fffa7..c05c512767 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -39,6 +39,13 @@ extern char **environ;
 #include "qemu/clang-tsa.h"
 
 #include "qemu-os.h"
+/*
+ * TODO: Remove these and rely only on qemu_real_host_page_size().
+ */
+extern uintptr_t qemu_host_page_size;
+extern intptr_t qemu_host_page_mask;
+#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
+
 /*
  * This struct is used to hold certain information about the image.  Basically,
  * it replicates in user space what would be certain task_struct fields in the
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 9ead1be100..6346df17ce 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -20,13 +20,6 @@
 void cpu_exec_init_all(void);
 void cpu_exec_step_atomic(CPUState *cpu);
 
-/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even
- * when intptr_t is 32-bit and we are aligning a long long.
- */
-extern uintptr_t qemu_host_page_size;
-extern intptr_t qemu_host_page_mask;
-
-#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
 #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size())
 
 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 4385ce54c9..5c2d55f6d2 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1179,8 +1179,6 @@ bool target_words_bigendian(void);
 
 const char *target_name(void);
 
-void page_size_init(void);
-
 #ifdef NEED_CPU_H
 
 #ifndef CONFIG_USER_ONLY
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 1c695efe02..c1f57e894a 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -256,7 +256,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data)
 
 void page_init(void)
 {
-    page_size_init();
     page_table_config_init();
 }
 
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 6ab3efd6c0..512d4ab69f 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -49,6 +49,13 @@
 #include "host-os.h"
 #include "target_arch_cpu.h"
 
+
+/*
+ * TODO: Remove these and rely only on qemu_real_host_page_size().
+ */
+uintptr_t qemu_host_page_size;
+intptr_t qemu_host_page_mask;
+
 static bool opt_one_insn_per_tb;
 uintptr_t guest_base;
 bool have_guest_base;
@@ -307,6 +314,9 @@ int main(int argc, char **argv)
         (void) envlist_setenv(envlist, *wrk);
     }
 
+    qemu_host_page_size = getpagesize();
+    qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE);
+
     cpu_model = NULL;
 
     qemu_add_opts(&qemu_trace_opts);
@@ -404,6 +414,8 @@ int main(int argc, char **argv)
         }
     }
 
+    qemu_host_page_mask = -qemu_host_page_size;
+
     /* init debug */
     {
         int mask = 0;
diff --git a/cpu-target.c b/cpu-target.c
index 86444cc2c6..4c0621bf33 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -45,9 +45,6 @@
 #include "trace/trace-root.h"
 #include "qemu/accel.h"
 
-uintptr_t qemu_host_page_size;
-intptr_t qemu_host_page_mask;
-
 #ifndef CONFIG_USER_ONLY
 static int cpu_common_post_load(void *opaque, int version_id)
 {
@@ -474,16 +471,3 @@ const char *target_name(void)
 {
     return TARGET_NAME;
 }
-
-void page_size_init(void)
-{
-    /* NOTE: we can always suppose that qemu_host_page_size >=
-       TARGET_PAGE_SIZE */
-    if (qemu_host_page_size == 0) {
-        qemu_host_page_size = qemu_real_host_page_size();
-    }
-    if (qemu_host_page_size < TARGET_PAGE_SIZE) {
-        qemu_host_page_size = TARGET_PAGE_SIZE;
-    }
-    qemu_host_page_mask = -(intptr_t)qemu_host_page_size;
-}
diff --git a/system/vl.c b/system/vl.c
index b8469d9965..7913cc28aa 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2118,7 +2118,6 @@ static void qemu_create_machine(QDict *qdict)
     }
 
     cpu_exec_init_all();
-    page_size_init();
 
     if (machine_class->hw_version) {
         qemu_set_hw_version(machine_class->hw_version);
-- 
2.34.1



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

* Re: [PULL v2 00/39] tcg and linux-user patch queue
  2024-02-24  1:05 [PULL v2 00/39] tcg and linux-user patch queue Richard Henderson
  2024-02-24  1:05 ` [PULL v2 31/39] *-user: Deprecate and disable -p pagesize Richard Henderson
  2024-02-24  1:05 ` [PULL v2 32/39] cpu: Remove page_size_init Richard Henderson
@ 2024-02-24 16:15 ` Peter Maydell
  2024-02-24 20:56   ` Richard Henderson
  2 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2024-02-24 16:15 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel

On Sat, 24 Feb 2024 at 01:06, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> v2: Fix bsd-user build errors.
>
>
> r~
>
>
> The following changes since commit 3d54cbf269d63ff1d500b35b2bcf4565ff8ad485:
>
>   Merge tag 'hw-misc-20240222' of https://github.com/philmd/qemu into staging (2024-02-22 15:44:29 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20240222-2
>
> for you to fetch changes up to fcc6ad372f56d3f47b6d5457a904916b48b9e114:
>
>   linux-user: Remove pgb_dynamic alignment assertion (2024-02-23 15:07:03 -0800)
>
> ----------------------------------------------------------------
> tcg/aarch64: Apple does not align __int128_t in even registers
> accel/tcg: Fixes for page tables in mmio memory
> linux-user: Remove qemu_host_page_{size,mask}, HOST_PAGE_ALIGN
> migration: Remove qemu_host_page_size
> hw/tpm: Remove qemu_host_page_size
> softmmu: Remove qemu_host_page_{size,mask}, HOST_PAGE_ALIGN
> linux-user: Split and reorganize target_mmap.
> *-user: Deprecate and disable -p pagesize
> linux-user: Allow TARGET_PAGE_BITS_VARY
> target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only
> target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only
> target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only
> linux-user: Remove pgb_dynamic alignment assertion
>
> ----------------------------------------------------------------

Hi -- looks like this introduces an new variable-length-array, which
we are trying to get rid of:

../linux-user/elfload.c: In function 'vma_dump_size':
../linux-user/elfload.c:4254:9: error: ISO C90 forbids variable length
array 'page' [-Werror=vla]
4254 | char page[TARGET_PAGE_SIZE];
| ^~~~
../linux-user/elfload.c: In function 'elf_core_dump':
../linux-user/elfload.c:4778:13: error: ISO C90 forbids variable
length array 'page' [-Werror=vla]
4778 | char page[TARGET_PAGE_SIZE];
| ^~~~

I noticed this because I happened to test merging this pullreq
together with Thomas's testing pullreq that enforces the -Wvla
error. I'll be merging that testing pull shortly but it's not
upstream quite yet.

thanks
-- PMM


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

* Re: [PULL v2 00/39] tcg and linux-user patch queue
  2024-02-24 16:15 ` [PULL v2 00/39] tcg and linux-user patch queue Peter Maydell
@ 2024-02-24 20:56   ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2024-02-24 20:56 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On 2/24/24 06:15, Peter Maydell wrote:
> Hi -- looks like this introduces an new variable-length-array, which
> we are trying to get rid of:
> 
> ../linux-user/elfload.c: In function 'vma_dump_size':
> ../linux-user/elfload.c:4254:9: error: ISO C90 forbids variable length
> array 'page' [-Werror=vla]
> 4254 | char page[TARGET_PAGE_SIZE];
> | ^~~~
> ../linux-user/elfload.c: In function 'elf_core_dump':
> ../linux-user/elfload.c:4778:13: error: ISO C90 forbids variable
> length array 'page' [-Werror=vla]
> 4778 | char page[TARGET_PAGE_SIZE];
> | ^~~~
> 
> I noticed this because I happened to test merging this pullreq
> together with Thomas's testing pullreq that enforces the -Wvla
> error. I'll be merging that testing pull shortly but it's not
> upstream quite yet.

Ok, please merge Thomas' first and I'll fix this up.
It looks like we should be dynamically allocating these anyway.


r~


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

end of thread, other threads:[~2024-02-24 20:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-24  1:05 [PULL v2 00/39] tcg and linux-user patch queue Richard Henderson
2024-02-24  1:05 ` [PULL v2 31/39] *-user: Deprecate and disable -p pagesize Richard Henderson
2024-02-24  1:05 ` [PULL v2 32/39] cpu: Remove page_size_init Richard Henderson
2024-02-24 16:15 ` [PULL v2 00/39] tcg and linux-user patch queue Peter Maydell
2024-02-24 20:56   ` Richard Henderson

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).