Re: [RFC PATCH 1/2] bulk: Replace !CONFIG_SOFTMMU -> CONFIG_USER_ONLY

2023-06-05 Thread Richard Henderson

On 6/5/23 13:29, Philippe Mathieu-Daudé wrote:

On 3/6/23 05:49, Richard Henderson wrote:

On 6/2/23 15:58, Philippe Mathieu-Daudé wrote:

CONFIG_USER_ONLY is the opposite of CONFIG_SOFTMMU.
Replace !CONFIG_SOFTMMU negation by the positive form
which is clearer when reviewing code.


CONFIG_SOFTMMU should be reserved for the actual softmmu tlb, which we *should* be able 
to enable for user-only.  It is the only way to handle some of our host/guest page size 
problems.  Further, CONFIG_SOFTMMU should go away as a #define and become a runtime test 
(forced to true for system mode).  Pie in the sky stuff.


This would be:

   bool has_softmmu(void)
   {
   #ifdef CONFIG_USER_ONLY
   /* TODO: implement */
   return false;
   #else
   return true;
   #endif
   }

?


Yes, something like that.


r~



Re: [RFC PATCH 1/2] bulk: Replace !CONFIG_SOFTMMU -> CONFIG_USER_ONLY

2023-06-05 Thread Philippe Mathieu-Daudé

On 3/6/23 05:49, Richard Henderson wrote:

On 6/2/23 15:58, Philippe Mathieu-Daudé wrote:

CONFIG_USER_ONLY is the opposite of CONFIG_SOFTMMU.
Replace !CONFIG_SOFTMMU negation by the positive form
which is clearer when reviewing code.


CONFIG_SOFTMMU should be reserved for the actual softmmu tlb, which we 
*should* be able to enable for user-only.  It is the only way to handle 
some of our host/guest page size problems.  Further, CONFIG_SOFTMMU 
should go away as a #define and become a runtime test (forced to true 
for system mode).  Pie in the sky stuff.


This would be:

  bool has_softmmu(void)
  {
  #ifdef CONFIG_USER_ONLY
  /* TODO: implement */
  return false;
  #else
  return true;
  #endif
  }

?

It is quite likely that all uses of CONFIG_SOFTMMU outside of tcg/, 
accel/tcg/, and random bits of include/ should only be using 
CONFIG_USER_ONLY.


I see.

Thanks,

Phil.



Re: [RFC PATCH 1/2] bulk: Replace !CONFIG_SOFTMMU -> CONFIG_USER_ONLY

2023-06-02 Thread Richard Henderson

On 6/2/23 15:58, Philippe Mathieu-Daudé wrote:

CONFIG_USER_ONLY is the opposite of CONFIG_SOFTMMU.
Replace !CONFIG_SOFTMMU negation by the positive form
which is clearer when reviewing code.


CONFIG_SOFTMMU should be reserved for the actual softmmu tlb, which we *should* be able to 
enable for user-only.  It is the only way to handle some of our host/guest page size 
problems.  Further, CONFIG_SOFTMMU should go away as a #define and become a runtime test 
(forced to true for system mode).  Pie in the sky stuff.


It is quite likely that all uses of CONFIG_SOFTMMU outside of tcg/, accel/tcg/, and random 
bits of include/ should only be using CONFIG_USER_ONLY.



r~



[RFC PATCH 1/2] bulk: Replace !CONFIG_SOFTMMU -> CONFIG_USER_ONLY

2023-06-02 Thread Philippe Mathieu-Daudé
CONFIG_USER_ONLY is the opposite of CONFIG_SOFTMMU.
Replace !CONFIG_SOFTMMU negation by the positive form
which is clearer when reviewing code.

Change mostly done mechanically using:

  $ sed -i -e 's/!defined(CONFIG_SOFTMMU)/defined(CONFIG_USER_ONLY)/' \
   -e 's/ifndef CONFIG_SOFTMMU/ifdef CONFIG_USER_ONLY/' \
   $(git grep -l CONFIG_SOFTMMU)

and adapting comments manually.

Signed-off-by: Philippe Mathieu-Daudé 
---
 accel/tcg/cpu-exec.c | 4 ++--
 target/i386/helper.c | 6 +++---
 tcg/aarch64/tcg-target.c.inc | 4 ++--
 tcg/arm/tcg-target.c.inc | 4 ++--
 tcg/i386/tcg-target.c.inc| 8 
 tcg/loongarch64/tcg-target.c.inc | 4 ++--
 tcg/mips/tcg-target.c.inc| 6 +++---
 tcg/ppc/tcg-target.c.inc | 4 ++--
 tcg/riscv/tcg-target.c.inc   | 2 +-
 tcg/s390x/tcg-target.c.inc   | 4 ++--
 tcg/sparc64/tcg-target.c.inc | 4 ++--
 11 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index f1eae7b8e5..d5695a7083 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -568,7 +568,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
 cpu_tb_exec(cpu, tb, _exit);
 cpu_exec_exit(cpu);
 } else {
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 clear_helper_retaddr();
 if (have_mmap_lock()) {
 mmap_unlock();
@@ -1025,7 +1025,7 @@ static int cpu_exec_setjmp(CPUState *cpu, SyncClocks *sc)
 /* Non-buggy compilers preserve this; assert the correct value. */
 g_assert(cpu == current_cpu);
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 clear_helper_retaddr();
 if (have_mmap_lock()) {
 mmap_unlock();
diff --git a/target/i386/helper.c b/target/i386/helper.c
index 89aa696c6d..c9755b3aba 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -582,7 +582,7 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int 
selector,
 
 void do_cpu_init(X86CPU *cpu)
 {
-#if !defined(CONFIG_USER_ONLY)
+#if defined(CONFIG_SOFTMMU)
 CPUState *cs = CPU(cpu);
 CPUX86State *env = >env;
 CPUX86State *save = g_new(CPUX86State, 1);
@@ -601,10 +601,10 @@ void do_cpu_init(X86CPU *cpu)
 kvm_arch_do_init_vcpu(cpu);
 }
 apic_init_reset(cpu->apic_state);
-#endif /* CONFIG_USER_ONLY */
+#endif /* CONFIG_SOFTMMU */
 }
 
-#ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_SOFTMMU
 
 void do_cpu_sipi(X86CPU *cpu)
 {
diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc
index 35ca80cd56..d82654ac64 100644
--- a/tcg/aarch64/tcg-target.c.inc
+++ b/tcg/aarch64/tcg-target.c.inc
@@ -77,7 +77,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind 
kind, int slot)
 #define TCG_REG_TMP2 TCG_REG_X30
 #define TCG_VEC_TMP0 TCG_REG_V31
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 #define TCG_REG_GUEST_BASE TCG_REG_X28
 #endif
 
@@ -3083,7 +3083,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
 tcg_set_frame(s, TCG_REG_SP, TCG_STATIC_CALL_ARGS_SIZE,
   CPU_TEMP_BUF_NLONGS * sizeof(long));
 
-#if !defined(CONFIG_SOFTMMU)
+#if defined(CONFIG_USER_ONLY)
 /*
  * Note that XZR cannot be encoded in the address base register slot,
  * as that actaully encodes SP.  Depending on the guest, we may need
diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc
index 83e286088f..9248c1eb2a 100644
--- a/tcg/arm/tcg-target.c.inc
+++ b/tcg/arm/tcg-target.c.inc
@@ -89,7 +89,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind 
kind, int slot)
 
 #define TCG_REG_TMP  TCG_REG_R12
 #define TCG_VEC_TMP  TCG_REG_Q15
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 #define TCG_REG_GUEST_BASE  TCG_REG_R11
 #endif
 
@@ -2920,7 +2920,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
 
 tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]);
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 if (guest_base) {
 tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_GUEST_BASE, guest_base);
 tcg_regset_set_reg(s->reserved_regs, TCG_REG_GUEST_BASE);
diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc
index ab997b5fb3..fa3ef70417 100644
--- a/tcg/i386/tcg-target.c.inc
+++ b/tcg/i386/tcg-target.c.inc
@@ -1866,7 +1866,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, 
TCGLabelQemuLdst *l)
 return true;
 }
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 static HostAddress x86_guest_base = {
 .index = -1
 };
@@ -1898,7 +1898,7 @@ static inline int setup_guest_base_seg(void)
 return 0;
 }
 #endif /* setup_guest_base_seg */
-#endif /* !SOFTMMU */
+#endif /* CONFIG_USER_ONLY */
 
 #define MIN_TLB_MASK_TABLE_OFS  INT_MIN
 
@@ -4069,7 +4069,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
  (ARRAY_SIZE(tcg_target_callee_save_regs) + 2) * 4
  + stack_addend);
 #else
-# if !defined(CONFIG_SOFTMMU)
+# if defined(CONFIG_USER_ONLY)