public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: Change [g|h]va_t as u64
@ 2026-03-06  4:11 Anshuman Khandual
  2026-03-06  9:55 ` kernel test robot
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Anshuman Khandual @ 2026-03-06  4:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: Anshuman Khandual, Paolo Bonzini, kvm

Change both [g|h]va_t as u64 to be consistent with other address types.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 include/linux/kvm_types.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
index a568d8e6f4e8..c901ad01eb5d 100644
--- a/include/linux/kvm_types.h
+++ b/include/linux/kvm_types.h
@@ -61,15 +61,15 @@ enum kvm_mr_change;
  *  hfn - host frame number
  */
 
-typedef unsigned long  gva_t;
-typedef u64            gpa_t;
-typedef u64            gfn_t;
+typedef u64  gva_t;
+typedef u64  gpa_t;
+typedef u64  gfn_t;
 
 #define INVALID_GPA	(~(gpa_t)0)
 
-typedef unsigned long  hva_t;
-typedef u64            hpa_t;
-typedef u64            hfn_t;
+typedef u64  hva_t;
+typedef u64  hpa_t;
+typedef u64  hfn_t;
 
 typedef hfn_t kvm_pfn_t;
 
-- 
2.30.2


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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-06  4:11 [PATCH] KVM: Change [g|h]va_t as u64 Anshuman Khandual
@ 2026-03-06  9:55 ` kernel test robot
  2026-03-06 10:26 ` kernel test robot
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-03-06  9:55 UTC (permalink / raw)
  To: Anshuman Khandual, linux-kernel
  Cc: llvm, oe-kbuild-all, Anshuman Khandual, Paolo Bonzini, kvm

Hi Anshuman,

kernel test robot noticed the following build errors:

[auto build test ERROR on kvm/queue]
[also build test ERROR on kvm/next kvm/linux-next linus/master v7.0-rc2 next-20260305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Anshuman-Khandual/KVM-Change-g-h-va_t-as-u64/20260306-123029
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link:    https://lore.kernel.org/r/20260306041125.45643-1-anshuman.khandual%40arm.com
patch subject: [PATCH] KVM: Change [g|h]va_t as u64
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260306/202603061007.7Z2iBYzb-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260306/202603061007.7Z2iBYzb-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603061007.7Z2iBYzb-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from arch/x86/kvm/x86.c:89:
   In file included from arch/x86/kvm/trace.h:1976:
   In file included from include/trace/define_trace.h:132:
   In file included from include/trace/trace_events.h:256:
>> arch/x86/kvm/trace.h:973:40: warning: format specifies type 'unsigned long' but the argument has type 'gva_t' (aka 'unsigned long long') [-Wformat]
     954 |                 __field(gpa_t, gpa)
         |                 ~~~~~~~~~~~~~~~~~~~
     955 |                 __field(bool, write)
         |                 ~~~~~~~~~~~~~~~~~~~~
     956 |                 __field(bool, gpa_match)
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~
     957 |                 ),
         |                 ~~
     958 | 
     959 |         TP_fast_assign(
         |         ~~~~~~~~~~~~~~~
     960 |                 __entry->gva = gva;
         |                 ~~~~~~~~~~~~~~~~~~~
     961 |                 __entry->gpa = gpa;
         |                 ~~~~~~~~~~~~~~~~~~~
     962 |                 __entry->write = write;
         |                 ~~~~~~~~~~~~~~~~~~~~~~~
     963 |                 __entry->gpa_match = gpa_match
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     964 |                 ),
         |                 ~~
     965 | 
     966 |         TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                        %#llx
     967 |                   __entry->write ? "Write" : "Read",
         |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     968 |                   __entry->gpa_match ? "GPA" : "GVA")
         |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     969 | );
         | ~
   include/trace/stages/stage3_trace_output.h:6:17: note: expanded from macro '__entry'
       6 | #define __entry field
         |                 ^
   include/trace/stages/stage3_trace_output.h:9:43: note: expanded from macro 'TP_printk'
       9 | #define TP_printk(fmt, args...) fmt "\n", args
         |                                 ~~~       ^
   include/trace/trace_events.h:45:16: note: expanded from macro 'TRACE_EVENT'
      40 |         DECLARE_EVENT_CLASS(name,                              \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      41 |                              PARAMS(proto),                    \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      42 |                              PARAMS(args),                     \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      43 |                              PARAMS(tstruct),                  \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      44 |                              PARAMS(assign),                   \
         |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      45 |                              PARAMS(print));                   \
         |                              ~~~~~~~^~~~~~~
   include/linux/tracepoint.h:140:25: note: expanded from macro 'PARAMS'
     140 | #define PARAMS(args...) args
         |                         ^~~~
   include/trace/trace_events.h:219:27: note: expanded from macro 'DECLARE_EVENT_CLASS'
     219 |         trace_event_printf(iter, print);                                \
         |                                  ^~~~~
>> arch/x86/kvm/x86.c:8897:25: error: incompatible function pointer types initializing 'int (*)(struct x86_emulate_ctxt *, unsigned long, void *, unsigned int, struct x86_exception *, bool)' (aka 'int (*)(struct x86_emulate_ctxt *, unsigned long, void *, unsigned int, struct x86_exception *, _Bool)') with an expression of type 'int (struct x86_emulate_ctxt *, gva_t, void *, unsigned int, struct x86_exception *, bool)' (aka 'int (struct x86_emulate_ctxt *, unsigned long long, void *, unsigned int, struct x86_exception *, _Bool)') [-Wincompatible-function-pointer-types]
    8897 |         .read_std            = emulator_read_std,
         |                                ^~~~~~~~~~~~~~~~~
   arch/x86/kvm/x86.c:8898:25: error: incompatible function pointer types initializing 'int (*)(struct x86_emulate_ctxt *, unsigned long, void *, unsigned int, struct x86_exception *, bool)' (aka 'int (*)(struct x86_emulate_ctxt *, unsigned long, void *, unsigned int, struct x86_exception *, _Bool)') with an expression of type 'int (struct x86_emulate_ctxt *, gva_t, void *, unsigned int, struct x86_exception *, bool)' (aka 'int (struct x86_emulate_ctxt *, unsigned long long, void *, unsigned int, struct x86_exception *, _Bool)') [-Wincompatible-function-pointer-types]
    8898 |         .write_std           = emulator_write_std,
         |                                ^~~~~~~~~~~~~~~~~~
>> arch/x86/kvm/x86.c:8899:25: error: incompatible function pointer types initializing 'int (*)(struct x86_emulate_ctxt *, unsigned long, void *, unsigned int, struct x86_exception *)' with an expression of type 'int (struct x86_emulate_ctxt *, gva_t, void *, unsigned int, struct x86_exception *)' (aka 'int (struct x86_emulate_ctxt *, unsigned long long, void *, unsigned int, struct x86_exception *)') [-Wincompatible-function-pointer-types]
    8899 |         .fetch               = kvm_fetch_guest_virt,
         |                                ^~~~~~~~~~~~~~~~~~~~
   1 warning and 3 errors generated.
--
>> arch/x86/kvm/vmx/vmx.c:574:15: warning: format specifies type 'unsigned long' but the argument has type 'gva_t' (aka 'unsigned long long') [-Wformat]
     573 |         vmx_insn_failed("invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n",
         |                                                                  ~~~
         |                                                                  %llx
     574 |                         ext, vpid, gva);
         |                                    ^~~
   arch/x86/kvm/vmx/vmx.c:532:22: note: expanded from macro 'vmx_insn_failed'
     532 |         pr_warn_ratelimited(fmt);       \
         |                             ^~~
   include/linux/printk.h:721:49: note: expanded from macro 'pr_warn_ratelimited'
     721 |         printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |                                                ~~~     ^~~~~~~~~~~
   include/linux/printk.h:705:17: note: expanded from macro 'printk_ratelimited'
     705 |                 printk(fmt, ##__VA_ARGS__);                             \
         |                        ~~~    ^~~~~~~~~~~
   include/linux/printk.h:511:60: note: expanded from macro 'printk'
     511 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
         |                                                     ~~~    ^~~~~~~~~~~
   include/linux/printk.h:483:19: note: expanded from macro 'printk_index_wrap'
     483 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ~~~~    ^~~~~~~~~~~
   1 warning generated.


vim +8897 arch/x86/kvm/x86.c

16ccadefa295af arch/x86/kvm/x86.c Maxim Levitsky      2024-09-06  8892  
0225fb509d51fc arch/x86/kvm/x86.c Mathias Krause      2012-08-30  8893  static const struct x86_emulate_ops emulate_ops = {
1cca2f8c501fa0 arch/x86/kvm/x86.c Sean Christopherson 2022-05-26  8894  	.vm_bugged           = emulator_vm_bugged,
dd856efafe6097 arch/x86/kvm/x86.c Avi Kivity          2012-08-27  8895  	.read_gpr            = emulator_read_gpr,
dd856efafe6097 arch/x86/kvm/x86.c Avi Kivity          2012-08-27  8896  	.write_gpr           = emulator_write_gpr,
ce14e868a54ede arch/x86/kvm/x86.c Paolo Bonzini       2018-06-06 @8897  	.read_std            = emulator_read_std,
ce14e868a54ede arch/x86/kvm/x86.c Paolo Bonzini       2018-06-06  8898  	.write_std           = emulator_write_std,
1871c6020d7308 arch/x86/kvm/x86.c Gleb Natapov        2010-02-10 @8899  	.fetch               = kvm_fetch_guest_virt,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8900  	.read_emulated       = emulator_read_emulated,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8901  	.write_emulated      = emulator_write_emulated,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8902  	.cmpxchg_emulated    = emulator_cmpxchg_emulated,
3cb16fe78ce919 arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8903  	.invlpg              = emulator_invlpg,
cf8f70bfe38b32 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8904  	.pio_in_emulated     = emulator_pio_in_emulated,
cf8f70bfe38b32 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8905  	.pio_out_emulated    = emulator_pio_out_emulated,
1aa366163b8b69 arch/x86/kvm/x86.c Avi Kivity          2011-04-27  8906  	.get_segment         = emulator_get_segment,
1aa366163b8b69 arch/x86/kvm/x86.c Avi Kivity          2011-04-27  8907  	.set_segment         = emulator_set_segment,
5951c442372475 arch/x86/kvm/x86.c Gleb Natapov        2010-04-28  8908  	.get_cached_segment_base = emulator_get_cached_segment_base,
2dafc6c234b606 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8909  	.get_gdt             = emulator_get_gdt,
160ce1f1a8fe64 arch/x86/kvm/x86.c Mohammed Gamal      2010-08-04  8910  	.get_idt	     = emulator_get_idt,
1ac9d0cfb07e8a arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8911  	.set_gdt             = emulator_set_gdt,
1ac9d0cfb07e8a arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8912  	.set_idt	     = emulator_set_idt,
52a4661737ecc9 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8913  	.get_cr              = emulator_get_cr,
52a4661737ecc9 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8914  	.set_cr              = emulator_set_cr,
9c5372445c1ad4 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8915  	.cpl                 = emulator_get_cpl,
35aa5375d407ec arch/x86/kvm/x86.c Gleb Natapov        2010-04-28  8916  	.get_dr              = emulator_get_dr,
35aa5375d407ec arch/x86/kvm/x86.c Gleb Natapov        2010-04-28  8917  	.set_dr              = emulator_set_dr,
ac8d6cad3c7b39 arch/x86/kvm/x86.c Hou Wenlong         2022-03-07  8918  	.set_msr_with_filter = emulator_set_msr_with_filter,
ac8d6cad3c7b39 arch/x86/kvm/x86.c Hou Wenlong         2022-03-07  8919  	.get_msr_with_filter = emulator_get_msr_with_filter,
717746e382e58f arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8920  	.get_msr             = emulator_get_msr,
7bb7fce13601d2 arch/x86/kvm/x86.c Sean Christopherson 2024-01-09  8921  	.check_rdpmc_early   = emulator_check_rdpmc_early,
222d21aa070a48 arch/x86/kvm/x86.c Avi Kivity          2011-11-10  8922  	.read_pmc            = emulator_read_pmc,
6c3287f7c50500 arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8923  	.halt                = emulator_halt,
bcaf5cc543bdb8 arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8924  	.wbinvd              = emulator_wbinvd,
d6aa10003b0cde arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8925  	.fix_hypercall       = emulator_fix_hypercall,
c4f035c60dad45 arch/x86/kvm/x86.c Avi Kivity          2011-04-04  8926  	.intercept           = emulator_intercept,
bdb42f5afebe20 arch/x86/kvm/x86.c Stephan Bärwolf     2012-01-12  8927  	.get_cpuid           = emulator_get_cpuid,
5ae78e95ed0c77 arch/x86/kvm/x86.c Sean Christopherson 2019-12-17  8928  	.guest_has_movbe     = emulator_guest_has_movbe,
5ae78e95ed0c77 arch/x86/kvm/x86.c Sean Christopherson 2019-12-17  8929  	.guest_has_fxsr      = emulator_guest_has_fxsr,
a836839cbfe60d arch/x86/kvm/x86.c Hou Wenlong         2022-03-02  8930  	.guest_has_rdpid     = emulator_guest_has_rdpid,
d99e4cb2ae2e02 arch/x86/kvm/x86.c Sean Christopherson 2024-04-05  8931  	.guest_cpuid_is_intel_compatible = emulator_guest_cpuid_is_intel_compatible,
801806d956c2c1 arch/x86/kvm/x86.c Nadav Amit          2015-01-26  8932  	.set_nmi_mask        = emulator_set_nmi_mask,
32e69f232db4ca arch/x86/kvm/x86.c Maxim Levitsky      2022-11-29  8933  	.is_smm              = emulator_is_smm,
ecc513e5bb7ed5 arch/x86/kvm/x86.c Sean Christopherson 2021-06-09  8934  	.leave_smm           = emulator_leave_smm,
25b17226cd9a77 arch/x86/kvm/x86.c Sean Christopherson 2021-06-09  8935  	.triple_fault        = emulator_triple_fault,
f106797f81d633 arch/x86/kvm/x86.c Paolo Bonzini       2025-11-13  8936  	.get_xcr             = emulator_get_xcr,
02d4160fbd7651 arch/x86/kvm/x86.c Vitaly Kuznetsov    2019-08-13  8937  	.set_xcr             = emulator_set_xcr,
37a41847b770c7 arch/x86/kvm/x86.c Binbin Wu           2023-09-13  8938  	.get_untagged_addr   = emulator_get_untagged_addr,
16ccadefa295af arch/x86/kvm/x86.c Maxim Levitsky      2024-09-06  8939  	.is_canonical_addr   = emulator_is_canonical_addr,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8940  };
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8941  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-06  4:11 [PATCH] KVM: Change [g|h]va_t as u64 Anshuman Khandual
  2026-03-06  9:55 ` kernel test robot
@ 2026-03-06 10:26 ` kernel test robot
  2026-03-06 13:48 ` kernel test robot
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-03-06 10:26 UTC (permalink / raw)
  To: Anshuman Khandual, linux-kernel
  Cc: oe-kbuild-all, Anshuman Khandual, Paolo Bonzini, kvm

Hi Anshuman,

kernel test robot noticed the following build errors:

[auto build test ERROR on kvm/queue]
[also build test ERROR on kvm/next linus/master v7.0-rc2 next-20260305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Anshuman-Khandual/KVM-Change-g-h-va_t-as-u64/20260306-123029
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link:    https://lore.kernel.org/r/20260306041125.45643-1-anshuman.khandual%40arm.com
patch subject: [PATCH] KVM: Change [g|h]va_t as u64
config: x86_64-rhel-9.4-ltp (https://download.01.org/0day-ci/archive/20260306/202603061115.VQTqyi2i-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260306/202603061115.VQTqyi2i-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603061115.VQTqyi2i-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:132,
                    from arch/x86/kvm/trace.h:1976,
                    from arch/x86/kvm/x86.c:89:
   include/trace/../../arch/x86/kvm/trace.h: In function 'trace_raw_output_vcpu_match_mmio':
>> include/trace/../../arch/x86/kvm/trace.h:973:19: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'gva_t' {aka 'long long unsigned int'} [-Wformat=]
     973 |         TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/trace/trace_events.h:219:34: note: in definition of macro 'DECLARE_EVENT_CLASS'
     219 |         trace_event_printf(iter, print);                                \
         |                                  ^~~~~
   include/trace/trace_events.h:45:30: note: in expansion of macro 'PARAMS'
      45 |                              PARAMS(print));                   \
         |                              ^~~~~~
   include/trace/../../arch/x86/kvm/trace.h:954:1: note: in expansion of macro 'TRACE_EVENT'
     954 | TRACE_EVENT(
         | ^~~~~~~~~~~
   include/trace/../../arch/x86/kvm/trace.h:973:9: note: in expansion of macro 'TP_printk'
     973 |         TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
         |         ^~~~~~~~~
   In file included from include/trace/trace_events.h:256:
   include/trace/../../arch/x86/kvm/trace.h:973:27: note: format string is defined here
     973 |         TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
         |                        ~~~^
         |                           |
         |                           long unsigned int
         |                        %#llx
   arch/x86/kvm/x86.c: At top level:
>> arch/x86/kvm/x86.c:8897:32: error: initialization of 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} from incompatible pointer type 'int (*)(struct x86_emulate_ctxt *, gva_t,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} [-Wincompatible-pointer-types]
    8897 |         .read_std            = emulator_read_std,
         |                                ^~~~~~~~~~~~~~~~~
   arch/x86/kvm/x86.c:8897:32: note: (near initialization for 'emulate_ops.read_std')
   arch/x86/kvm/x86.c:8898:32: error: initialization of 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} from incompatible pointer type 'int (*)(struct x86_emulate_ctxt *, gva_t,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} [-Wincompatible-pointer-types]
    8898 |         .write_std           = emulator_write_std,
         |                                ^~~~~~~~~~~~~~~~~~
   arch/x86/kvm/x86.c:8898:32: note: (near initialization for 'emulate_ops.write_std')
>> arch/x86/kvm/x86.c:8899:32: error: initialization of 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *)' from incompatible pointer type 'int (*)(struct x86_emulate_ctxt *, gva_t,  void *, unsigned int,  struct x86_exception *)' {aka 'int (*)(struct x86_emulate_ctxt *, long long unsigned int,  void *, unsigned int,  struct x86_exception *)'} [-Wincompatible-pointer-types]
    8899 |         .fetch               = kvm_fetch_guest_virt,
         |                                ^~~~~~~~~~~~~~~~~~~~
   arch/x86/kvm/x86.c:8899:32: note: (near initialization for 'emulate_ops.fetch')
--
   In file included from include/asm-generic/bug.h:31,
                    from arch/x86/include/asm/bug.h:193,
                    from arch/x86/include/asm/alternative.h:9,
                    from arch/x86/include/asm/segment.h:6,
                    from arch/x86/include/asm/ptrace.h:5,
                    from arch/x86/include/asm/math_emu.h:5,
                    from arch/x86/include/asm/processor.h:13,
                    from arch/x86/include/asm/timex.h:5,
                    from include/linux/timex.h:67,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/fs_dirent.h:5,
                    from include/linux/fs/super_types.h:5,
                    from include/linux/fs/super.h:5,
                    from include/linux/fs.h:5,
                    from include/linux/highmem.h:5,
                    from arch/x86/kvm/vmx/vmx.c:17:
   arch/x86/kvm/vmx/vmx.c: In function 'invvpid_error':
>> include/linux/kern_levels.h:5:25: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'gva_t' {aka 'long long unsigned int'} [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/printk.h:483:25: note: in definition of macro 'printk_index_wrap'
     483 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ^~~~
   include/linux/printk.h:705:17: note: in expansion of macro 'printk'
     705 |                 printk(fmt, ##__VA_ARGS__);                             \
         |                 ^~~~~~
   include/linux/printk.h:721:9: note: in expansion of macro 'printk_ratelimited'
     721 |         printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~~
   include/linux/kern_levels.h:12:25: note: in expansion of macro 'KERN_SOH'
      12 | #define KERN_WARNING    KERN_SOH "4"    /* warning conditions */
         |                         ^~~~~~~~
   include/linux/printk.h:721:28: note: in expansion of macro 'KERN_WARNING'
     721 |         printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |                            ^~~~~~~~~~~~
   arch/x86/kvm/vmx/vmx.c:532:9: note: in expansion of macro 'pr_warn_ratelimited'
     532 |         pr_warn_ratelimited(fmt);       \
         |         ^~~~~~~~~~~~~~~~~~~
   arch/x86/kvm/vmx/vmx.c:573:9: note: in expansion of macro 'vmx_insn_failed'
     573 |         vmx_insn_failed("invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n",
         |         ^~~~~~~~~~~~~~~
--
   In file included from include/trace/define_trace.h:132,
                    from kvm/trace.h:1976,
                    from kvm/x86.c:89:
   include/trace/../../arch/x86/kvm/trace.h: In function 'trace_raw_output_vcpu_match_mmio':
>> include/trace/../../arch/x86/kvm/trace.h:973:19: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'gva_t' {aka 'long long unsigned int'} [-Wformat=]
     973 |         TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/trace/trace_events.h:219:34: note: in definition of macro 'DECLARE_EVENT_CLASS'
     219 |         trace_event_printf(iter, print);                                \
         |                                  ^~~~~
   include/trace/trace_events.h:45:30: note: in expansion of macro 'PARAMS'
      45 |                              PARAMS(print));                   \
         |                              ^~~~~~
   include/trace/../../arch/x86/kvm/trace.h:954:1: note: in expansion of macro 'TRACE_EVENT'
     954 | TRACE_EVENT(
         | ^~~~~~~~~~~
   include/trace/../../arch/x86/kvm/trace.h:973:9: note: in expansion of macro 'TP_printk'
     973 |         TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
         |         ^~~~~~~~~
   In file included from include/trace/trace_events.h:256:
   include/trace/../../arch/x86/kvm/trace.h:973:27: note: format string is defined here
     973 |         TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
         |                        ~~~^
         |                           |
         |                           long unsigned int
         |                        %#llx
   kvm/x86.c: At top level:
   kvm/x86.c:8897:32: error: initialization of 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} from incompatible pointer type 'int (*)(struct x86_emulate_ctxt *, gva_t,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} [-Wincompatible-pointer-types]
    8897 |         .read_std            = emulator_read_std,
         |                                ^~~~~~~~~~~~~~~~~
   kvm/x86.c:8897:32: note: (near initialization for 'emulate_ops.read_std')
   kvm/x86.c:8898:32: error: initialization of 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} from incompatible pointer type 'int (*)(struct x86_emulate_ctxt *, gva_t,  void *, unsigned int,  struct x86_exception *, bool)' {aka 'int (*)(struct x86_emulate_ctxt *, long long unsigned int,  void *, unsigned int,  struct x86_exception *, _Bool)'} [-Wincompatible-pointer-types]
    8898 |         .write_std           = emulator_write_std,
         |                                ^~~~~~~~~~~~~~~~~~
   kvm/x86.c:8898:32: note: (near initialization for 'emulate_ops.write_std')
   kvm/x86.c:8899:32: error: initialization of 'int (*)(struct x86_emulate_ctxt *, long unsigned int,  void *, unsigned int,  struct x86_exception *)' from incompatible pointer type 'int (*)(struct x86_emulate_ctxt *, gva_t,  void *, unsigned int,  struct x86_exception *)' {aka 'int (*)(struct x86_emulate_ctxt *, long long unsigned int,  void *, unsigned int,  struct x86_exception *)'} [-Wincompatible-pointer-types]
    8899 |         .fetch               = kvm_fetch_guest_virt,
         |                                ^~~~~~~~~~~~~~~~~~~~
   kvm/x86.c:8899:32: note: (near initialization for 'emulate_ops.fetch')
--
   In file included from include/asm-generic/bug.h:31,
                    from arch/x86/include/asm/bug.h:193,
                    from arch/x86/include/asm/alternative.h:9,
                    from arch/x86/include/asm/segment.h:6,
                    from arch/x86/include/asm/ptrace.h:5,
                    from arch/x86/include/asm/math_emu.h:5,
                    from arch/x86/include/asm/processor.h:13,
                    from arch/x86/include/asm/timex.h:5,
                    from include/linux/timex.h:67,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/fs_dirent.h:5,
                    from include/linux/fs/super_types.h:5,
                    from include/linux/fs/super.h:5,
                    from include/linux/fs.h:5,
                    from include/linux/highmem.h:5,
                    from kvm/vmx/vmx.c:17:
   kvm/vmx/vmx.c: In function 'invvpid_error':
>> include/linux/kern_levels.h:5:25: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'gva_t' {aka 'long long unsigned int'} [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/printk.h:483:25: note: in definition of macro 'printk_index_wrap'
     483 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ^~~~
   include/linux/printk.h:705:17: note: in expansion of macro 'printk'
     705 |                 printk(fmt, ##__VA_ARGS__);                             \
         |                 ^~~~~~
   include/linux/printk.h:721:9: note: in expansion of macro 'printk_ratelimited'
     721 |         printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~~
   include/linux/kern_levels.h:12:25: note: in expansion of macro 'KERN_SOH'
      12 | #define KERN_WARNING    KERN_SOH "4"    /* warning conditions */
         |                         ^~~~~~~~
   include/linux/printk.h:721:28: note: in expansion of macro 'KERN_WARNING'
     721 |         printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |                            ^~~~~~~~~~~~
   kvm/vmx/vmx.c:532:9: note: in expansion of macro 'pr_warn_ratelimited'
     532 |         pr_warn_ratelimited(fmt);       \
         |         ^~~~~~~~~~~~~~~~~~~
   kvm/vmx/vmx.c:573:9: note: in expansion of macro 'vmx_insn_failed'
     573 |         vmx_insn_failed("invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n",
         |         ^~~~~~~~~~~~~~~


vim +8897 arch/x86/kvm/x86.c

16ccadefa295af arch/x86/kvm/x86.c Maxim Levitsky      2024-09-06  8892  
0225fb509d51fc arch/x86/kvm/x86.c Mathias Krause      2012-08-30  8893  static const struct x86_emulate_ops emulate_ops = {
1cca2f8c501fa0 arch/x86/kvm/x86.c Sean Christopherson 2022-05-26  8894  	.vm_bugged           = emulator_vm_bugged,
dd856efafe6097 arch/x86/kvm/x86.c Avi Kivity          2012-08-27  8895  	.read_gpr            = emulator_read_gpr,
dd856efafe6097 arch/x86/kvm/x86.c Avi Kivity          2012-08-27  8896  	.write_gpr           = emulator_write_gpr,
ce14e868a54ede arch/x86/kvm/x86.c Paolo Bonzini       2018-06-06 @8897  	.read_std            = emulator_read_std,
ce14e868a54ede arch/x86/kvm/x86.c Paolo Bonzini       2018-06-06  8898  	.write_std           = emulator_write_std,
1871c6020d7308 arch/x86/kvm/x86.c Gleb Natapov        2010-02-10 @8899  	.fetch               = kvm_fetch_guest_virt,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8900  	.read_emulated       = emulator_read_emulated,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8901  	.write_emulated      = emulator_write_emulated,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8902  	.cmpxchg_emulated    = emulator_cmpxchg_emulated,
3cb16fe78ce919 arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8903  	.invlpg              = emulator_invlpg,
cf8f70bfe38b32 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8904  	.pio_in_emulated     = emulator_pio_in_emulated,
cf8f70bfe38b32 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8905  	.pio_out_emulated    = emulator_pio_out_emulated,
1aa366163b8b69 arch/x86/kvm/x86.c Avi Kivity          2011-04-27  8906  	.get_segment         = emulator_get_segment,
1aa366163b8b69 arch/x86/kvm/x86.c Avi Kivity          2011-04-27  8907  	.set_segment         = emulator_set_segment,
5951c442372475 arch/x86/kvm/x86.c Gleb Natapov        2010-04-28  8908  	.get_cached_segment_base = emulator_get_cached_segment_base,
2dafc6c234b606 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8909  	.get_gdt             = emulator_get_gdt,
160ce1f1a8fe64 arch/x86/kvm/x86.c Mohammed Gamal      2010-08-04  8910  	.get_idt	     = emulator_get_idt,
1ac9d0cfb07e8a arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8911  	.set_gdt             = emulator_set_gdt,
1ac9d0cfb07e8a arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8912  	.set_idt	     = emulator_set_idt,
52a4661737ecc9 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8913  	.get_cr              = emulator_get_cr,
52a4661737ecc9 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8914  	.set_cr              = emulator_set_cr,
9c5372445c1ad4 arch/x86/kvm/x86.c Gleb Natapov        2010-03-18  8915  	.cpl                 = emulator_get_cpl,
35aa5375d407ec arch/x86/kvm/x86.c Gleb Natapov        2010-04-28  8916  	.get_dr              = emulator_get_dr,
35aa5375d407ec arch/x86/kvm/x86.c Gleb Natapov        2010-04-28  8917  	.set_dr              = emulator_set_dr,
ac8d6cad3c7b39 arch/x86/kvm/x86.c Hou Wenlong         2022-03-07  8918  	.set_msr_with_filter = emulator_set_msr_with_filter,
ac8d6cad3c7b39 arch/x86/kvm/x86.c Hou Wenlong         2022-03-07  8919  	.get_msr_with_filter = emulator_get_msr_with_filter,
717746e382e58f arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8920  	.get_msr             = emulator_get_msr,
7bb7fce13601d2 arch/x86/kvm/x86.c Sean Christopherson 2024-01-09  8921  	.check_rdpmc_early   = emulator_check_rdpmc_early,
222d21aa070a48 arch/x86/kvm/x86.c Avi Kivity          2011-11-10  8922  	.read_pmc            = emulator_read_pmc,
6c3287f7c50500 arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8923  	.halt                = emulator_halt,
bcaf5cc543bdb8 arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8924  	.wbinvd              = emulator_wbinvd,
d6aa10003b0cde arch/x86/kvm/x86.c Avi Kivity          2011-04-20  8925  	.fix_hypercall       = emulator_fix_hypercall,
c4f035c60dad45 arch/x86/kvm/x86.c Avi Kivity          2011-04-04  8926  	.intercept           = emulator_intercept,
bdb42f5afebe20 arch/x86/kvm/x86.c Stephan Bärwolf     2012-01-12  8927  	.get_cpuid           = emulator_get_cpuid,
5ae78e95ed0c77 arch/x86/kvm/x86.c Sean Christopherson 2019-12-17  8928  	.guest_has_movbe     = emulator_guest_has_movbe,
5ae78e95ed0c77 arch/x86/kvm/x86.c Sean Christopherson 2019-12-17  8929  	.guest_has_fxsr      = emulator_guest_has_fxsr,
a836839cbfe60d arch/x86/kvm/x86.c Hou Wenlong         2022-03-02  8930  	.guest_has_rdpid     = emulator_guest_has_rdpid,
d99e4cb2ae2e02 arch/x86/kvm/x86.c Sean Christopherson 2024-04-05  8931  	.guest_cpuid_is_intel_compatible = emulator_guest_cpuid_is_intel_compatible,
801806d956c2c1 arch/x86/kvm/x86.c Nadav Amit          2015-01-26  8932  	.set_nmi_mask        = emulator_set_nmi_mask,
32e69f232db4ca arch/x86/kvm/x86.c Maxim Levitsky      2022-11-29  8933  	.is_smm              = emulator_is_smm,
ecc513e5bb7ed5 arch/x86/kvm/x86.c Sean Christopherson 2021-06-09  8934  	.leave_smm           = emulator_leave_smm,
25b17226cd9a77 arch/x86/kvm/x86.c Sean Christopherson 2021-06-09  8935  	.triple_fault        = emulator_triple_fault,
f106797f81d633 arch/x86/kvm/x86.c Paolo Bonzini       2025-11-13  8936  	.get_xcr             = emulator_get_xcr,
02d4160fbd7651 arch/x86/kvm/x86.c Vitaly Kuznetsov    2019-08-13  8937  	.set_xcr             = emulator_set_xcr,
37a41847b770c7 arch/x86/kvm/x86.c Binbin Wu           2023-09-13  8938  	.get_untagged_addr   = emulator_get_untagged_addr,
16ccadefa295af arch/x86/kvm/x86.c Maxim Levitsky      2024-09-06  8939  	.is_canonical_addr   = emulator_is_canonical_addr,
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8940  };
bbd9b64e37aff5 drivers/kvm/x86.c  Carsten Otte        2007-10-30  8941  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-06  4:11 [PATCH] KVM: Change [g|h]va_t as u64 Anshuman Khandual
  2026-03-06  9:55 ` kernel test robot
  2026-03-06 10:26 ` kernel test robot
@ 2026-03-06 13:48 ` kernel test robot
  2026-03-06 15:30 ` kernel test robot
  2026-03-06 18:16 ` Sean Christopherson
  4 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-03-06 13:48 UTC (permalink / raw)
  To: Anshuman Khandual, linux-kernel
  Cc: oe-kbuild-all, Anshuman Khandual, Paolo Bonzini, kvm

Hi Anshuman,

kernel test robot noticed the following build warnings:

[auto build test WARNING on kvm/queue]
[also build test WARNING on kvm/next kvm/linux-next linus/master v7.0-rc2 next-20260305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Anshuman-Khandual/KVM-Change-g-h-va_t-as-u64/20260306-123029
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link:    https://lore.kernel.org/r/20260306041125.45643-1-anshuman.khandual%40arm.com
patch subject: [PATCH] KVM: Change [g|h]va_t as u64
config: i386-buildonly-randconfig-002-20260306 (https://download.01.org/0day-ci/archive/20260306/202603062132.hgMBAT4f-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260306/202603062132.hgMBAT4f-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603062132.hgMBAT4f-lkp@intel.com/

All warnings (new ones prefixed by >>):

   arch/x86/kvm/xen.c: In function 'kvm_xen_write_hypercall_page':
>> arch/x86/kvm/xen.c:1350:36: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    1350 |                 page = memdup_user((u8 __user *)blob_addr, PAGE_SIZE);
         |                                    ^
   arch/x86/kvm/xen.c: In function 'kvm_xen_schedop_poll':
>> arch/x86/kvm/xen.c:1525:39: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    1525 |         if (kvm_read_guest_virt(vcpu, (gva_t)sched_poll.ports, ports,
         |                                       ^
--
   In file included from arch/x86/include/asm/bug.h:193,
                    from arch/x86/include/asm/alternative.h:9,
                    from arch/x86/include/asm/barrier.h:5,
                    from include/asm-generic/bitops/generic-non-atomic.h:7,
                    from include/linux/bitops.h:28,
                    from include/linux/log2.h:12,
                    from arch/x86/include/asm/div64.h:8,
                    from include/linux/math.h:6,
                    from include/linux/math64.h:6,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/fs_dirent.h:5,
                    from include/linux/fs/super_types.h:5,
                    from include/linux/fs/super.h:5,
                    from include/linux/fs.h:5,
                    from include/linux/highmem.h:5,
                    from arch/x86/kvm/vmx/vmx.c:17:
   arch/x86/kvm/vmx/vmx.c: In function 'invvpid_error':
>> arch/x86/kvm/vmx/vmx.c:573:25: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'gva_t' {aka 'long long unsigned int'} [-Wformat=]
     573 |         vmx_insn_failed("invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n",
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     574 |                         ext, vpid, gva);
         |                                    ~~~
         |                                    |
         |                                    gva_t {aka long long unsigned int}
   include/asm-generic/bug.h:133:31: note: in definition of macro '__WARN_printf'
     133 |                 __warn_printk(arg);                                     \
         |                               ^~~
   include/linux/once_lite.h:31:25: note: in expansion of macro 'WARN'
      31 |                         func(__VA_ARGS__);                              \
         |                         ^~~~
   include/asm-generic/bug.h:185:9: note: in expansion of macro 'DO_ONCE_LITE_IF'
     185 |         DO_ONCE_LITE_IF(condition, WARN, 1, format)
         |         ^~~~~~~~~~~~~~~
   arch/x86/kvm/vmx/vmx.c:531:9: note: in expansion of macro 'WARN_ONCE'
     531 |         WARN_ONCE(1, fmt);              \
         |         ^~~~~~~~~
   arch/x86/kvm/vmx/vmx.c:573:9: note: in expansion of macro 'vmx_insn_failed'
     573 |         vmx_insn_failed("invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n",
         |         ^~~~~~~~~~~~~~~
   arch/x86/kvm/vmx/vmx.c:573:68: note: format string is defined here
     573 |         vmx_insn_failed("invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n",
         |                                                                  ~~^
         |                                                                    |
         |                                                                    long unsigned int
         |                                                                  %llx
   In file included from include/asm-generic/bug.h:31:
>> include/linux/kern_levels.h:5:25: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'gva_t' {aka 'long long unsigned int'} [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/printk.h:483:25: note: in definition of macro 'printk_index_wrap'
     483 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ^~~~
   include/linux/printk.h:705:17: note: in expansion of macro 'printk'
     705 |                 printk(fmt, ##__VA_ARGS__);                             \
         |                 ^~~~~~
   include/linux/printk.h:721:9: note: in expansion of macro 'printk_ratelimited'
     721 |         printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~~
   include/linux/kern_levels.h:12:25: note: in expansion of macro 'KERN_SOH'
      12 | #define KERN_WARNING    KERN_SOH "4"    /* warning conditions */
         |                         ^~~~~~~~
   include/linux/printk.h:721:28: note: in expansion of macro 'KERN_WARNING'
     721 |         printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         |                            ^~~~~~~~~~~~
   arch/x86/kvm/vmx/vmx.c:532:9: note: in expansion of macro 'pr_warn_ratelimited'
     532 |         pr_warn_ratelimited(fmt);       \
         |         ^~~~~~~~~~~~~~~~~~~
   arch/x86/kvm/vmx/vmx.c:573:9: note: in expansion of macro 'vmx_insn_failed'
     573 |         vmx_insn_failed("invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n",
         |         ^~~~~~~~~~~~~~~


vim +1350 arch/x86/kvm/xen.c

3e3246158808d46 David Woodhouse     2021-02-02  1275  
23200b7a30de315 Joao Martins        2018-06-13  1276  int kvm_xen_write_hypercall_page(struct kvm_vcpu *vcpu, u64 data)
23200b7a30de315 Joao Martins        2018-06-13  1277  {
23200b7a30de315 Joao Martins        2018-06-13  1278  	struct kvm *kvm = vcpu->kvm;
23200b7a30de315 Joao Martins        2018-06-13  1279  	u32 page_num = data & ~PAGE_MASK;
23200b7a30de315 Joao Martins        2018-06-13  1280  	u64 page_addr = data & PAGE_MASK;
a3833b81b05d0ae David Woodhouse     2020-12-03  1281  	bool lm = is_long_mode(vcpu);
18b99e4d6db65ff Paul Durrant        2024-02-15  1282  	int r = 0;
a3833b81b05d0ae David Woodhouse     2020-12-03  1283  
18b99e4d6db65ff Paul Durrant        2024-02-15  1284  	mutex_lock(&kvm->arch.xen.xen_lock);
18b99e4d6db65ff Paul Durrant        2024-02-15  1285  	if (kvm->arch.xen.long_mode != lm) {
18b99e4d6db65ff Paul Durrant        2024-02-15  1286  		kvm->arch.xen.long_mode = lm;
18b99e4d6db65ff Paul Durrant        2024-02-15  1287  
18b99e4d6db65ff Paul Durrant        2024-02-15  1288  		/*
18b99e4d6db65ff Paul Durrant        2024-02-15  1289  		 * Re-initialize shared_info to put the wallclock in the
18b99e4d6db65ff Paul Durrant        2024-02-15  1290  		 * correct place.
18b99e4d6db65ff Paul Durrant        2024-02-15  1291  		 */
18b99e4d6db65ff Paul Durrant        2024-02-15  1292  		if (kvm->arch.xen.shinfo_cache.active &&
18b99e4d6db65ff Paul Durrant        2024-02-15  1293  		    kvm_xen_shared_info_init(kvm))
18b99e4d6db65ff Paul Durrant        2024-02-15  1294  			r = 1;
18b99e4d6db65ff Paul Durrant        2024-02-15  1295  	}
18b99e4d6db65ff Paul Durrant        2024-02-15  1296  	mutex_unlock(&kvm->arch.xen.xen_lock);
18b99e4d6db65ff Paul Durrant        2024-02-15  1297  
18b99e4d6db65ff Paul Durrant        2024-02-15  1298  	if (r)
18b99e4d6db65ff Paul Durrant        2024-02-15  1299  		return r;
23200b7a30de315 Joao Martins        2018-06-13  1300  
23200b7a30de315 Joao Martins        2018-06-13  1301  	/*
23200b7a30de315 Joao Martins        2018-06-13  1302  	 * If Xen hypercall intercept is enabled, fill the hypercall
23200b7a30de315 Joao Martins        2018-06-13  1303  	 * page with VMCALL/VMMCALL instructions since that's what
23200b7a30de315 Joao Martins        2018-06-13  1304  	 * we catch. Else the VMM has provided the hypercall pages
23200b7a30de315 Joao Martins        2018-06-13  1305  	 * with instructions of its own choosing, so use those.
23200b7a30de315 Joao Martins        2018-06-13  1306  	 */
23200b7a30de315 Joao Martins        2018-06-13  1307  	if (kvm_xen_hypercall_enabled(kvm)) {
23200b7a30de315 Joao Martins        2018-06-13  1308  		u8 instructions[32];
23200b7a30de315 Joao Martins        2018-06-13  1309  		int i;
23200b7a30de315 Joao Martins        2018-06-13  1310  
23200b7a30de315 Joao Martins        2018-06-13  1311  		if (page_num)
23200b7a30de315 Joao Martins        2018-06-13  1312  			return 1;
23200b7a30de315 Joao Martins        2018-06-13  1313  
23200b7a30de315 Joao Martins        2018-06-13  1314  		/* mov imm32, %eax */
23200b7a30de315 Joao Martins        2018-06-13  1315  		instructions[0] = 0xb8;
23200b7a30de315 Joao Martins        2018-06-13  1316  
23200b7a30de315 Joao Martins        2018-06-13  1317  		/* vmcall / vmmcall */
896046474f8d2ea Wei Wang            2024-05-07  1318  		kvm_x86_call(patch_hypercall)(vcpu, instructions + 5);
23200b7a30de315 Joao Martins        2018-06-13  1319  
23200b7a30de315 Joao Martins        2018-06-13  1320  		/* ret */
23200b7a30de315 Joao Martins        2018-06-13  1321  		instructions[8] = 0xc3;
23200b7a30de315 Joao Martins        2018-06-13  1322  
23200b7a30de315 Joao Martins        2018-06-13  1323  		/* int3 to pad */
23200b7a30de315 Joao Martins        2018-06-13  1324  		memset(instructions + 9, 0xcc, sizeof(instructions) - 9);
23200b7a30de315 Joao Martins        2018-06-13  1325  
23200b7a30de315 Joao Martins        2018-06-13  1326  		for (i = 0; i < PAGE_SIZE / sizeof(instructions); i++) {
23200b7a30de315 Joao Martins        2018-06-13  1327  			*(u32 *)&instructions[1] = i;
23200b7a30de315 Joao Martins        2018-06-13  1328  			if (kvm_vcpu_write_guest(vcpu,
23200b7a30de315 Joao Martins        2018-06-13  1329  						 page_addr + (i * sizeof(instructions)),
23200b7a30de315 Joao Martins        2018-06-13  1330  						 instructions, sizeof(instructions)))
23200b7a30de315 Joao Martins        2018-06-13  1331  				return 1;
23200b7a30de315 Joao Martins        2018-06-13  1332  		}
23200b7a30de315 Joao Martins        2018-06-13  1333  	} else {
448841f0b7b50f1 Sean Christopherson 2021-02-08  1334  		/*
448841f0b7b50f1 Sean Christopherson 2021-02-08  1335  		 * Note, truncation is a non-issue as 'lm' is guaranteed to be
448841f0b7b50f1 Sean Christopherson 2021-02-08  1336  		 * false for a 32-bit kernel, i.e. when hva_t is only 4 bytes.
448841f0b7b50f1 Sean Christopherson 2021-02-08  1337  		 */
26e228ec1695011 Sean Christopherson 2025-02-14  1338  		hva_t blob_addr = lm ? kvm->arch.xen.hvm_config.blob_addr_64
26e228ec1695011 Sean Christopherson 2025-02-14  1339  				     : kvm->arch.xen.hvm_config.blob_addr_32;
26e228ec1695011 Sean Christopherson 2025-02-14  1340  		u8 blob_size = lm ? kvm->arch.xen.hvm_config.blob_size_64
26e228ec1695011 Sean Christopherson 2025-02-14  1341  				  : kvm->arch.xen.hvm_config.blob_size_32;
23200b7a30de315 Joao Martins        2018-06-13  1342  		u8 *page;
385407a69d51408 Michal Luczaj       2022-12-26  1343  		int ret;
23200b7a30de315 Joao Martins        2018-06-13  1344  
23200b7a30de315 Joao Martins        2018-06-13  1345  		if (page_num >= blob_size)
23200b7a30de315 Joao Martins        2018-06-13  1346  			return 1;
23200b7a30de315 Joao Martins        2018-06-13  1347  
23200b7a30de315 Joao Martins        2018-06-13  1348  		blob_addr += page_num * PAGE_SIZE;
23200b7a30de315 Joao Martins        2018-06-13  1349  
23200b7a30de315 Joao Martins        2018-06-13 @1350  		page = memdup_user((u8 __user *)blob_addr, PAGE_SIZE);
23200b7a30de315 Joao Martins        2018-06-13  1351  		if (IS_ERR(page))
23200b7a30de315 Joao Martins        2018-06-13  1352  			return PTR_ERR(page);
23200b7a30de315 Joao Martins        2018-06-13  1353  
385407a69d51408 Michal Luczaj       2022-12-26  1354  		ret = kvm_vcpu_write_guest(vcpu, page_addr, page, PAGE_SIZE);
23200b7a30de315 Joao Martins        2018-06-13  1355  		kfree(page);
385407a69d51408 Michal Luczaj       2022-12-26  1356  		if (ret)
23200b7a30de315 Joao Martins        2018-06-13  1357  			return 1;
23200b7a30de315 Joao Martins        2018-06-13  1358  	}
23200b7a30de315 Joao Martins        2018-06-13  1359  	return 0;
23200b7a30de315 Joao Martins        2018-06-13  1360  }
23200b7a30de315 Joao Martins        2018-06-13  1361  
78e9878cb376969 David Woodhouse     2021-02-02  1362  int kvm_xen_hvm_config(struct kvm *kvm, struct kvm_xen_hvm_config *xhc)
78e9878cb376969 David Woodhouse     2021-02-02  1363  {
661a20fab7d156c David Woodhouse     2022-03-03  1364  	/* Only some feature flags need to be *enabled* by userspace */
661a20fab7d156c David Woodhouse     2022-03-03  1365  	u32 permitted_flags = KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL |
6d7228352609085 Paul Durrant        2023-11-02  1366  		KVM_XEN_HVM_CONFIG_EVTCHN_SEND |
6d7228352609085 Paul Durrant        2023-11-02  1367  		KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE;
6d7228352609085 Paul Durrant        2023-11-02  1368  	u32 old_flags;
661a20fab7d156c David Woodhouse     2022-03-03  1369  
661a20fab7d156c David Woodhouse     2022-03-03  1370  	if (xhc->flags & ~permitted_flags)
78e9878cb376969 David Woodhouse     2021-02-02  1371  		return -EINVAL;
78e9878cb376969 David Woodhouse     2021-02-02  1372  
78e9878cb376969 David Woodhouse     2021-02-02  1373  	/*
78e9878cb376969 David Woodhouse     2021-02-02  1374  	 * With hypercall interception the kernel generates its own
78e9878cb376969 David Woodhouse     2021-02-02  1375  	 * hypercall page so it must not be provided.
78e9878cb376969 David Woodhouse     2021-02-02  1376  	 */
78e9878cb376969 David Woodhouse     2021-02-02  1377  	if ((xhc->flags & KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL) &&
78e9878cb376969 David Woodhouse     2021-02-02  1378  	    (xhc->blob_addr_32 || xhc->blob_addr_64 ||
78e9878cb376969 David Woodhouse     2021-02-02  1379  	     xhc->blob_size_32 || xhc->blob_size_64))
78e9878cb376969 David Woodhouse     2021-02-02  1380  		return -EINVAL;
78e9878cb376969 David Woodhouse     2021-02-02  1381  
5c17848134ab1ff Sean Christopherson 2025-02-14  1382  	/*
5c17848134ab1ff Sean Christopherson 2025-02-14  1383  	 * Restrict the MSR to the range that is unofficially reserved for
5c17848134ab1ff Sean Christopherson 2025-02-14  1384  	 * synthetic, virtualization-defined MSRs, e.g. to prevent confusing
5c17848134ab1ff Sean Christopherson 2025-02-14  1385  	 * KVM by colliding with a real MSR that requires special handling.
5c17848134ab1ff Sean Christopherson 2025-02-14  1386  	 */
5c17848134ab1ff Sean Christopherson 2025-02-14  1387  	if (xhc->msr &&
5c17848134ab1ff Sean Christopherson 2025-02-14  1388  	    (xhc->msr < KVM_XEN_MSR_MIN_INDEX || xhc->msr > KVM_XEN_MSR_MAX_INDEX))
5c17848134ab1ff Sean Christopherson 2025-02-14  1389  		return -EINVAL;
5c17848134ab1ff Sean Christopherson 2025-02-14  1390  
310bc39546a435c David Woodhouse     2023-01-11  1391  	mutex_lock(&kvm->arch.xen.xen_lock);
7d6bbebb7bb0294 David Woodhouse     2021-02-02  1392  
26e228ec1695011 Sean Christopherson 2025-02-14  1393  	if (xhc->msr && !kvm->arch.xen.hvm_config.msr)
7d6bbebb7bb0294 David Woodhouse     2021-02-02  1394  		static_branch_inc(&kvm_xen_enabled.key);
26e228ec1695011 Sean Christopherson 2025-02-14  1395  	else if (!xhc->msr && kvm->arch.xen.hvm_config.msr)
7d6bbebb7bb0294 David Woodhouse     2021-02-02  1396  		static_branch_slow_dec_deferred(&kvm_xen_enabled);
7d6bbebb7bb0294 David Woodhouse     2021-02-02  1397  
26e228ec1695011 Sean Christopherson 2025-02-14  1398  	old_flags = kvm->arch.xen.hvm_config.flags;
26e228ec1695011 Sean Christopherson 2025-02-14  1399  	memcpy(&kvm->arch.xen.hvm_config, xhc, sizeof(*xhc));
7d6bbebb7bb0294 David Woodhouse     2021-02-02  1400  
310bc39546a435c David Woodhouse     2023-01-11  1401  	mutex_unlock(&kvm->arch.xen.xen_lock);
6d7228352609085 Paul Durrant        2023-11-02  1402  
6d7228352609085 Paul Durrant        2023-11-02  1403  	if ((old_flags ^ xhc->flags) & KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE)
6d7228352609085 Paul Durrant        2023-11-02  1404  		kvm_make_all_cpus_request(kvm, KVM_REQ_CLOCK_UPDATE);
6d7228352609085 Paul Durrant        2023-11-02  1405  
78e9878cb376969 David Woodhouse     2021-02-02  1406  	return 0;
78e9878cb376969 David Woodhouse     2021-02-02  1407  }
78e9878cb376969 David Woodhouse     2021-02-02  1408  
23200b7a30de315 Joao Martins        2018-06-13  1409  static int kvm_xen_hypercall_set_result(struct kvm_vcpu *vcpu, u64 result)
23200b7a30de315 Joao Martins        2018-06-13  1410  {
23200b7a30de315 Joao Martins        2018-06-13  1411  	kvm_rax_write(vcpu, result);
23200b7a30de315 Joao Martins        2018-06-13  1412  	return kvm_skip_emulated_instruction(vcpu);
23200b7a30de315 Joao Martins        2018-06-13  1413  }
23200b7a30de315 Joao Martins        2018-06-13  1414  
23200b7a30de315 Joao Martins        2018-06-13  1415  static int kvm_xen_hypercall_complete_userspace(struct kvm_vcpu *vcpu)
23200b7a30de315 Joao Martins        2018-06-13  1416  {
23200b7a30de315 Joao Martins        2018-06-13  1417  	struct kvm_run *run = vcpu->run;
23200b7a30de315 Joao Martins        2018-06-13  1418  
23200b7a30de315 Joao Martins        2018-06-13  1419  	if (unlikely(!kvm_is_linear_rip(vcpu, vcpu->arch.xen.hypercall_rip)))
23200b7a30de315 Joao Martins        2018-06-13  1420  		return 1;
23200b7a30de315 Joao Martins        2018-06-13  1421  
23200b7a30de315 Joao Martins        2018-06-13  1422  	return kvm_xen_hypercall_set_result(vcpu, run->xen.u.hcall.result);
23200b7a30de315 Joao Martins        2018-06-13  1423  }
23200b7a30de315 Joao Martins        2018-06-13  1424  
4ea9439fd537313 David Woodhouse     2022-11-12  1425  static inline int max_evtchn_port(struct kvm *kvm)
4ea9439fd537313 David Woodhouse     2022-11-12  1426  {
4ea9439fd537313 David Woodhouse     2022-11-12  1427  	if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode)
4ea9439fd537313 David Woodhouse     2022-11-12  1428  		return EVTCHN_2L_NR_CHANNELS;
4ea9439fd537313 David Woodhouse     2022-11-12  1429  	else
4ea9439fd537313 David Woodhouse     2022-11-12  1430  		return COMPAT_EVTCHN_2L_NR_CHANNELS;
4ea9439fd537313 David Woodhouse     2022-11-12  1431  }
4ea9439fd537313 David Woodhouse     2022-11-12  1432  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1433  static bool wait_pending_event(struct kvm_vcpu *vcpu, int nr_ports,
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1434  			       evtchn_port_t *ports)
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1435  {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1436  	struct kvm *kvm = vcpu->kvm;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1437  	struct gfn_to_pfn_cache *gpc = &kvm->arch.xen.shinfo_cache;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1438  	unsigned long *pending_bits;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1439  	unsigned long flags;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1440  	bool ret = true;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1441  	int idx, i;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1442  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1443  	idx = srcu_read_lock(&kvm->srcu);
4265df667bbdc71 Peng Hao            2022-11-08  1444  	read_lock_irqsave(&gpc->lock, flags);
58f5ee5fedd981e Sean Christopherson 2022-10-13  1445  	if (!kvm_gpc_check(gpc, PAGE_SIZE))
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1446  		goto out_rcu;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1447  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1448  	ret = false;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1449  	if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1450  		struct shared_info *shinfo = gpc->khva;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1451  		pending_bits = (unsigned long *)&shinfo->evtchn_pending;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1452  	} else {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1453  		struct compat_shared_info *shinfo = gpc->khva;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1454  		pending_bits = (unsigned long *)&shinfo->evtchn_pending;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1455  	}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1456  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1457  	for (i = 0; i < nr_ports; i++) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1458  		if (test_bit(ports[i], pending_bits)) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1459  			ret = true;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1460  			break;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1461  		}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1462  	}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1463  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1464   out_rcu:
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1465  	read_unlock_irqrestore(&gpc->lock, flags);
4265df667bbdc71 Peng Hao            2022-11-08  1466  	srcu_read_unlock(&kvm->srcu, idx);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1467  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1468  	return ret;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1469  }
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1470  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1471  static bool kvm_xen_schedop_poll(struct kvm_vcpu *vcpu, bool longmode,
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1472  				 u64 param, u64 *r)
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1473  {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1474  	struct sched_poll sched_poll;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1475  	evtchn_port_t port, *ports;
92c58965e9656dc David Woodhouse     2022-12-26  1476  	struct x86_exception e;
92c58965e9656dc David Woodhouse     2022-12-26  1477  	int i;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1478  
214b0a88c46d5f3 Metin Kaya          2022-03-21  1479  	if (!lapic_in_kernel(vcpu) ||
26e228ec1695011 Sean Christopherson 2025-02-14  1480  	    !(vcpu->kvm->arch.xen.hvm_config.flags & KVM_XEN_HVM_CONFIG_EVTCHN_SEND))
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1481  		return false;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1482  
214b0a88c46d5f3 Metin Kaya          2022-03-21  1483  	if (IS_ENABLED(CONFIG_64BIT) && !longmode) {
214b0a88c46d5f3 Metin Kaya          2022-03-21  1484  		struct compat_sched_poll sp32;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1485  
214b0a88c46d5f3 Metin Kaya          2022-03-21  1486  		/* Sanity check that the compat struct definition is correct */
214b0a88c46d5f3 Metin Kaya          2022-03-21  1487  		BUILD_BUG_ON(sizeof(sp32) != 16);
214b0a88c46d5f3 Metin Kaya          2022-03-21  1488  
92c58965e9656dc David Woodhouse     2022-12-26  1489  		if (kvm_read_guest_virt(vcpu, param, &sp32, sizeof(sp32), &e)) {
214b0a88c46d5f3 Metin Kaya          2022-03-21  1490  			*r = -EFAULT;
214b0a88c46d5f3 Metin Kaya          2022-03-21  1491  			return true;
214b0a88c46d5f3 Metin Kaya          2022-03-21  1492  		}
214b0a88c46d5f3 Metin Kaya          2022-03-21  1493  
214b0a88c46d5f3 Metin Kaya          2022-03-21  1494  		/*
214b0a88c46d5f3 Metin Kaya          2022-03-21  1495  		 * This is a 32-bit pointer to an array of evtchn_port_t which
214b0a88c46d5f3 Metin Kaya          2022-03-21  1496  		 * are uint32_t, so once it's converted no further compat
214b0a88c46d5f3 Metin Kaya          2022-03-21  1497  		 * handling is needed.
214b0a88c46d5f3 Metin Kaya          2022-03-21  1498  		 */
214b0a88c46d5f3 Metin Kaya          2022-03-21  1499  		sched_poll.ports = (void *)(unsigned long)(sp32.ports);
214b0a88c46d5f3 Metin Kaya          2022-03-21  1500  		sched_poll.nr_ports = sp32.nr_ports;
214b0a88c46d5f3 Metin Kaya          2022-03-21  1501  		sched_poll.timeout = sp32.timeout;
214b0a88c46d5f3 Metin Kaya          2022-03-21  1502  	} else {
92c58965e9656dc David Woodhouse     2022-12-26  1503  		if (kvm_read_guest_virt(vcpu, param, &sched_poll,
92c58965e9656dc David Woodhouse     2022-12-26  1504  					sizeof(sched_poll), &e)) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1505  			*r = -EFAULT;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1506  			return true;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1507  		}
214b0a88c46d5f3 Metin Kaya          2022-03-21  1508  	}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1509  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1510  	if (unlikely(sched_poll.nr_ports > 1)) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1511  		/* Xen (unofficially) limits number of pollers to 128 */
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1512  		if (sched_poll.nr_ports > 128) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1513  			*r = -EINVAL;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1514  			return true;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1515  		}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1516  
bf4afc53b77aeaa Linus Torvalds      2026-02-21  1517  		ports = kmalloc_objs(*ports, sched_poll.nr_ports);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1518  		if (!ports) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1519  			*r = -ENOMEM;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1520  			return true;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1521  		}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1522  	} else
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1523  		ports = &port;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1524  
92c58965e9656dc David Woodhouse     2022-12-26 @1525  	if (kvm_read_guest_virt(vcpu, (gva_t)sched_poll.ports, ports,
92c58965e9656dc David Woodhouse     2022-12-26  1526  				sched_poll.nr_ports * sizeof(*ports), &e)) {
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1527  		*r = -EFAULT;
5a53249d149f48b Manuel Andreas      2025-07-23  1528  		goto out;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1529  	}
92c58965e9656dc David Woodhouse     2022-12-26  1530  
92c58965e9656dc David Woodhouse     2022-12-26  1531  	for (i = 0; i < sched_poll.nr_ports; i++) {
4ea9439fd537313 David Woodhouse     2022-11-12  1532  		if (ports[i] >= max_evtchn_port(vcpu->kvm)) {
4ea9439fd537313 David Woodhouse     2022-11-12  1533  			*r = -EINVAL;
4ea9439fd537313 David Woodhouse     2022-11-12  1534  			goto out;
4ea9439fd537313 David Woodhouse     2022-11-12  1535  		}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1536  	}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1537  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1538  	if (sched_poll.nr_ports == 1)
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1539  		vcpu->arch.xen.poll_evtchn = port;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1540  	else
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1541  		vcpu->arch.xen.poll_evtchn = -1;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1542  
79f772b9e8004c5 Sean Christopherson 2022-06-14  1543  	set_bit(vcpu->vcpu_idx, vcpu->kvm->arch.xen.poll_mask);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1544  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1545  	if (!wait_pending_event(vcpu, sched_poll.nr_ports, ports)) {
c9e5f3fa9039611 Jim Mattson         2025-01-13  1546  		kvm_set_mp_state(vcpu, KVM_MP_STATE_HALTED);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1547  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1548  		if (sched_poll.timeout)
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1549  			mod_timer(&vcpu->arch.xen.poll_timer,
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1550  				  jiffies + nsecs_to_jiffies(sched_poll.timeout));
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1551  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1552  		kvm_vcpu_halt(vcpu);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1553  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1554  		if (sched_poll.timeout)
8fa7292fee5c524 Thomas Gleixner     2025-04-05  1555  			timer_delete(&vcpu->arch.xen.poll_timer);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1556  
c9e5f3fa9039611 Jim Mattson         2025-01-13  1557  		kvm_set_mp_state(vcpu, KVM_MP_STATE_RUNNABLE);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1558  	}
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1559  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1560  	vcpu->arch.xen.poll_evtchn = 0;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1561  	*r = 0;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1562  out:
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1563  	/* Really, this is only needed in case of timeout */
79f772b9e8004c5 Sean Christopherson 2022-06-14  1564  	clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.xen.poll_mask);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1565  
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1566  	if (unlikely(sched_poll.nr_ports > 1))
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1567  		kfree(ports);
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1568  	return true;
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1569  }
1a65105a5aba9f7 Boris Ostrovsky     2022-03-03  1570  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-06  4:11 [PATCH] KVM: Change [g|h]va_t as u64 Anshuman Khandual
                   ` (2 preceding siblings ...)
  2026-03-06 13:48 ` kernel test robot
@ 2026-03-06 15:30 ` kernel test robot
  2026-03-06 18:16 ` Sean Christopherson
  4 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2026-03-06 15:30 UTC (permalink / raw)
  To: Anshuman Khandual, linux-kernel
  Cc: oe-kbuild-all, Anshuman Khandual, Paolo Bonzini, kvm

Hi Anshuman,

kernel test robot noticed the following build warnings:

[auto build test WARNING on kvm/queue]
[also build test WARNING on kvm/next kvm/linux-next linus/master v7.0-rc2 next-20260305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Anshuman-Khandual/KVM-Change-g-h-va_t-as-u64/20260306-123029
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link:    https://lore.kernel.org/r/20260306041125.45643-1-anshuman.khandual%40arm.com
patch subject: [PATCH] KVM: Change [g|h]va_t as u64
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20260306/202603062311.YDLuRUqh-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project c32caeec8158d634bb71ab8911a6031248b9fc47)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260306/202603062311.YDLuRUqh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603062311.YDLuRUqh-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/powerpc/kvm/book3s_64_mmu.c:253:42: warning: format specifies type 'unsigned long' but the argument has type 'hva_t' (aka 'unsigned long long') [-Wformat]
     253 |                         "KVM: Can't copy data from 0x%lx!\n", ptegp);
         |                                                      ~~~      ^~~~~
         |                                                      %llx
   include/linux/printk.h:705:17: note: expanded from macro 'printk_ratelimited'
     705 |                 printk(fmt, ##__VA_ARGS__);                             \
         |                        ~~~    ^~~~~~~~~~~
   include/linux/printk.h:511:60: note: expanded from macro 'printk'
     511 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
         |                                                     ~~~    ^~~~~~~~~~~
   include/linux/printk.h:483:19: note: expanded from macro 'printk_index_wrap'
     483 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ~~~~    ^~~~~~~~~~~
   1 warning generated.
--
>> arch/powerpc/kvm/book3s_32_mmu.c:211:42: warning: format specifies type 'unsigned long' but the argument has type 'hva_t' (aka 'unsigned long long') [-Wformat]
     211 |                         "KVM: Can't copy data from 0x%lx!\n", ptegp);
         |                                                      ~~~      ^~~~~
         |                                                      %llx
   include/linux/printk.h:705:17: note: expanded from macro 'printk_ratelimited'
     705 |                 printk(fmt, ##__VA_ARGS__);                             \
         |                        ~~~    ^~~~~~~~~~~
   include/linux/printk.h:511:60: note: expanded from macro 'printk'
     511 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
         |                                                     ~~~    ^~~~~~~~~~~
   include/linux/printk.h:483:19: note: expanded from macro 'printk_index_wrap'
     483 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ~~~~    ^~~~~~~~~~~
   1 warning generated.


vim +253 arch/powerpc/kvm/book3s_64_mmu.c

a4a0f2524acc2c6 Paul Mackerras       2013-09-20  190  
e71b2a39afff245 Alexander Graf       2009-10-30  191  static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
93b159b466bdc97 Paul Mackerras       2013-09-20  192  				      struct kvmppc_pte *gpte, bool data,
93b159b466bdc97 Paul Mackerras       2013-09-20  193  				      bool iswrite)
e71b2a39afff245 Alexander Graf       2009-10-30  194  {
e71b2a39afff245 Alexander Graf       2009-10-30  195  	struct kvmppc_slb *slbe;
e71b2a39afff245 Alexander Graf       2009-10-30  196  	hva_t ptegp;
e71b2a39afff245 Alexander Graf       2009-10-30  197  	u64 pteg[16];
e71b2a39afff245 Alexander Graf       2009-10-30  198  	u64 avpn = 0;
b352ddae7b2ccd2 Cédric Le Goater     2021-08-19  199  	u64 r;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  200  	u64 v_val, v_mask;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  201  	u64 eaddr_mask;
e71b2a39afff245 Alexander Graf       2009-10-30  202  	int i;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  203  	u8 pp, key = 0;
e71b2a39afff245 Alexander Graf       2009-10-30  204  	bool found = false;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  205  	bool second = false;
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  206  	int pgsize;
e8508940a88691a Alexander Graf       2010-07-29  207  	ulong mp_ea = vcpu->arch.magic_page_ea;
e8508940a88691a Alexander Graf       2010-07-29  208  
e8508940a88691a Alexander Graf       2010-07-29  209  	/* Magic page override */
e8508940a88691a Alexander Graf       2010-07-29  210  	if (unlikely(mp_ea) &&
e8508940a88691a Alexander Graf       2010-07-29  211  	    unlikely((eaddr & ~0xfffULL) == (mp_ea & ~0xfffULL)) &&
5deb8e7ad8ac7e3 Alexander Graf       2014-04-24  212  	    !(kvmppc_get_msr(vcpu) & MSR_PR)) {
e8508940a88691a Alexander Graf       2010-07-29  213  		gpte->eaddr = eaddr;
e8508940a88691a Alexander Graf       2010-07-29  214  		gpte->vpage = kvmppc_mmu_book3s_64_ea_to_vp(vcpu, eaddr, data);
e8508940a88691a Alexander Graf       2010-07-29  215  		gpte->raddr = vcpu->arch.magic_page_pa | (gpte->raddr & 0xfff);
e8508940a88691a Alexander Graf       2010-07-29  216  		gpte->raddr &= KVM_PAM;
e8508940a88691a Alexander Graf       2010-07-29  217  		gpte->may_execute = true;
e8508940a88691a Alexander Graf       2010-07-29  218  		gpte->may_read = true;
e8508940a88691a Alexander Graf       2010-07-29  219  		gpte->may_write = true;
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  220  		gpte->page_size = MMU_PAGE_4K;
6c7d47c33ed323f Alexey Kardashevskiy 2017-11-22  221  		gpte->wimg = HPTE_R_M;
e8508940a88691a Alexander Graf       2010-07-29  222  
e8508940a88691a Alexander Graf       2010-07-29  223  		return 0;
e8508940a88691a Alexander Graf       2010-07-29  224  	}
e71b2a39afff245 Alexander Graf       2009-10-30  225  
c4befc58a0cc5a8 Paul Mackerras       2011-06-29  226  	slbe = kvmppc_mmu_book3s_64_find_slbe(vcpu, eaddr);
e71b2a39afff245 Alexander Graf       2009-10-30  227  	if (!slbe)
e71b2a39afff245 Alexander Graf       2009-10-30  228  		goto no_seg_found;
e71b2a39afff245 Alexander Graf       2009-10-30  229  
0f296829b5a59d5 Paul Mackerras       2013-06-22  230  	avpn = kvmppc_mmu_book3s_64_get_avpn(slbe, eaddr);
7e48c101e0c53e6 Paul Mackerras       2013-08-06  231  	v_val = avpn & HPTE_V_AVPN;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  232  
0f296829b5a59d5 Paul Mackerras       2013-06-22  233  	if (slbe->tb)
7e48c101e0c53e6 Paul Mackerras       2013-08-06  234  		v_val |= SLB_VSID_B_1T;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  235  	if (slbe->large)
7e48c101e0c53e6 Paul Mackerras       2013-08-06  236  		v_val |= HPTE_V_LARGE;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  237  	v_val |= HPTE_V_VALID;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  238  
7e48c101e0c53e6 Paul Mackerras       2013-08-06  239  	v_mask = SLB_VSID_B | HPTE_V_AVPN | HPTE_V_LARGE | HPTE_V_VALID |
7e48c101e0c53e6 Paul Mackerras       2013-08-06  240  		HPTE_V_SECONDARY;
0f296829b5a59d5 Paul Mackerras       2013-06-22  241  
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  242  	pgsize = slbe->large ? MMU_PAGE_16M : MMU_PAGE_4K;
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  243  
9308ab8e2da933d Paul Mackerras       2013-09-20  244  	mutex_lock(&vcpu->kvm->arch.hpt_mutex);
9308ab8e2da933d Paul Mackerras       2013-09-20  245  
e71b2a39afff245 Alexander Graf       2009-10-30  246  do_second:
3ff955024d186c5 Paul Mackerras       2013-09-20  247  	ptegp = kvmppc_mmu_book3s_64_get_pteg(vcpu, slbe, eaddr, second);
e71b2a39afff245 Alexander Graf       2009-10-30  248  	if (kvm_is_error_hva(ptegp))
e71b2a39afff245 Alexander Graf       2009-10-30  249  		goto no_page_found;
e71b2a39afff245 Alexander Graf       2009-10-30  250  
e71b2a39afff245 Alexander Graf       2009-10-30  251  	if(copy_from_user(pteg, (void __user *)ptegp, sizeof(pteg))) {
4da934dc6515afa Vipin K Parashar     2017-02-16  252  		printk_ratelimited(KERN_ERR
4da934dc6515afa Vipin K Parashar     2017-02-16 @253  			"KVM: Can't copy data from 0x%lx!\n", ptegp);
e71b2a39afff245 Alexander Graf       2009-10-30  254  		goto no_page_found;
e71b2a39afff245 Alexander Graf       2009-10-30  255  	}
e71b2a39afff245 Alexander Graf       2009-10-30  256  
5deb8e7ad8ac7e3 Alexander Graf       2014-04-24  257  	if ((kvmppc_get_msr(vcpu) & MSR_PR) && slbe->Kp)
e71b2a39afff245 Alexander Graf       2009-10-30  258  		key = 4;
5deb8e7ad8ac7e3 Alexander Graf       2014-04-24  259  	else if (!(kvmppc_get_msr(vcpu) & MSR_PR) && slbe->Ks)
e71b2a39afff245 Alexander Graf       2009-10-30  260  		key = 4;
e71b2a39afff245 Alexander Graf       2009-10-30  261  
e71b2a39afff245 Alexander Graf       2009-10-30  262  	for (i=0; i<16; i+=2) {
4e509af9f83debe Alexander Graf       2014-04-24  263  		u64 pte0 = be64_to_cpu(pteg[i]);
4e509af9f83debe Alexander Graf       2014-04-24  264  		u64 pte1 = be64_to_cpu(pteg[i + 1]);
4e509af9f83debe Alexander Graf       2014-04-24  265  
7e48c101e0c53e6 Paul Mackerras       2013-08-06  266  		/* Check all relevant fields of 1st dword */
4e509af9f83debe Alexander Graf       2014-04-24  267  		if ((pte0 & v_mask) == v_val) {
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  268  			/* If large page bit is set, check pgsize encoding */
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  269  			if (slbe->large &&
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  270  			    (vcpu->arch.hflags & BOOK3S_HFLAG_MULTI_PGSIZE)) {
4e509af9f83debe Alexander Graf       2014-04-24  271  				pgsize = decode_pagesize(slbe, pte1);
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  272  				if (pgsize < 0)
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  273  					continue;
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  274  			}
7e48c101e0c53e6 Paul Mackerras       2013-08-06  275  			found = true;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  276  			break;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  277  		}
7e48c101e0c53e6 Paul Mackerras       2013-08-06  278  	}
e71b2a39afff245 Alexander Graf       2009-10-30  279  
7e48c101e0c53e6 Paul Mackerras       2013-08-06  280  	if (!found) {
7e48c101e0c53e6 Paul Mackerras       2013-08-06  281  		if (second)
7e48c101e0c53e6 Paul Mackerras       2013-08-06  282  			goto no_page_found;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  283  		v_val |= HPTE_V_SECONDARY;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  284  		second = true;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  285  		goto do_second;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  286  	}
e71b2a39afff245 Alexander Graf       2009-10-30  287  
4e509af9f83debe Alexander Graf       2014-04-24  288  	r = be64_to_cpu(pteg[i+1]);
7e48c101e0c53e6 Paul Mackerras       2013-08-06  289  	pp = (r & HPTE_R_PP) | key;
03a9c90334d611c Paul Mackerras       2013-09-20  290  	if (r & HPTE_R_PP0)
03a9c90334d611c Paul Mackerras       2013-09-20  291  		pp |= 8;
e71b2a39afff245 Alexander Graf       2009-10-30  292  
e71b2a39afff245 Alexander Graf       2009-10-30  293  	gpte->eaddr = eaddr;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  294  	gpte->vpage = kvmppc_mmu_book3s_64_ea_to_vp(vcpu, eaddr, data);
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  295  
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  296  	eaddr_mask = (1ull << mmu_pagesize(pgsize)) - 1;
7e48c101e0c53e6 Paul Mackerras       2013-08-06  297  	gpte->raddr = (r & HPTE_R_RPN & ~eaddr_mask) | (eaddr & eaddr_mask);
a4a0f2524acc2c6 Paul Mackerras       2013-09-20  298  	gpte->page_size = pgsize;
e71b2a39afff245 Alexander Graf       2009-10-30  299  	gpte->may_execute = ((r & HPTE_R_N) ? false : true);
f3383cf80e417e8 Alexander Graf       2014-05-12  300  	if (unlikely(vcpu->arch.disable_kernel_nx) &&
f3383cf80e417e8 Alexander Graf       2014-05-12  301  	    !(kvmppc_get_msr(vcpu) & MSR_PR))
f3383cf80e417e8 Alexander Graf       2014-05-12  302  		gpte->may_execute = true;
e71b2a39afff245 Alexander Graf       2009-10-30  303  	gpte->may_read = false;
e71b2a39afff245 Alexander Graf       2009-10-30  304  	gpte->may_write = false;
96df2267695199b Alexey Kardashevskiy 2017-03-24  305  	gpte->wimg = r & HPTE_R_WIMG;
e71b2a39afff245 Alexander Graf       2009-10-30  306  
e71b2a39afff245 Alexander Graf       2009-10-30  307  	switch (pp) {
e71b2a39afff245 Alexander Graf       2009-10-30  308  	case 0:
e71b2a39afff245 Alexander Graf       2009-10-30  309  	case 1:
e71b2a39afff245 Alexander Graf       2009-10-30  310  	case 2:
e71b2a39afff245 Alexander Graf       2009-10-30  311  	case 6:
e71b2a39afff245 Alexander Graf       2009-10-30  312  		gpte->may_write = true;
8fc6ba0a205e9ad Joe Perches          2020-03-10  313  		fallthrough;
e71b2a39afff245 Alexander Graf       2009-10-30  314  	case 3:
e71b2a39afff245 Alexander Graf       2009-10-30  315  	case 5:
e71b2a39afff245 Alexander Graf       2009-10-30  316  	case 7:
03a9c90334d611c Paul Mackerras       2013-09-20  317  	case 10:
e71b2a39afff245 Alexander Graf       2009-10-30  318  		gpte->may_read = true;
e71b2a39afff245 Alexander Graf       2009-10-30  319  		break;
e71b2a39afff245 Alexander Graf       2009-10-30  320  	}
e71b2a39afff245 Alexander Graf       2009-10-30  321  
e71b2a39afff245 Alexander Graf       2009-10-30  322  	dprintk("KVM MMU: Translated 0x%lx [0x%llx] -> 0x%llx "
af7b4d104b36e78 Alexander Graf       2010-04-20  323  		"-> 0x%lx\n",
e71b2a39afff245 Alexander Graf       2009-10-30  324  		eaddr, avpn, gpte->vpage, gpte->raddr);
e71b2a39afff245 Alexander Graf       2009-10-30  325  
e71b2a39afff245 Alexander Graf       2009-10-30  326  	/* Update PTE R and C bits, so the guest's swapper knows we used the
e71b2a39afff245 Alexander Graf       2009-10-30  327  	 * page */
9308ab8e2da933d Paul Mackerras       2013-09-20  328  	if (gpte->may_read && !(r & HPTE_R_R)) {
9308ab8e2da933d Paul Mackerras       2013-09-20  329  		/*
9308ab8e2da933d Paul Mackerras       2013-09-20  330  		 * Set the accessed flag.
9308ab8e2da933d Paul Mackerras       2013-09-20  331  		 * We have to write this back with a single byte write
9308ab8e2da933d Paul Mackerras       2013-09-20  332  		 * because another vcpu may be accessing this on
9308ab8e2da933d Paul Mackerras       2013-09-20  333  		 * non-PAPR platforms such as mac99, and this is
9308ab8e2da933d Paul Mackerras       2013-09-20  334  		 * what real hardware does.
9308ab8e2da933d Paul Mackerras       2013-09-20  335  		 */
740f834eb2505e1 Alexander Graf       2014-04-24  336                  char __user *addr = (char __user *) (ptegp + (i + 1) * sizeof(u64));
7e48c101e0c53e6 Paul Mackerras       2013-08-06  337  		r |= HPTE_R_R;
9308ab8e2da933d Paul Mackerras       2013-09-20  338  		put_user(r >> 8, addr + 6);
e71b2a39afff245 Alexander Graf       2009-10-30  339  	}
93b159b466bdc97 Paul Mackerras       2013-09-20  340  	if (iswrite && gpte->may_write && !(r & HPTE_R_C)) {
93b159b466bdc97 Paul Mackerras       2013-09-20  341  		/* Set the dirty flag */
9308ab8e2da933d Paul Mackerras       2013-09-20  342  		/* Use a single byte write */
740f834eb2505e1 Alexander Graf       2014-04-24  343                  char __user *addr = (char __user *) (ptegp + (i + 1) * sizeof(u64));
7e48c101e0c53e6 Paul Mackerras       2013-08-06  344  		r |= HPTE_R_C;
9308ab8e2da933d Paul Mackerras       2013-09-20  345  		put_user(r, addr + 7);
e71b2a39afff245 Alexander Graf       2009-10-30  346  	}
e71b2a39afff245 Alexander Graf       2009-10-30  347  
9308ab8e2da933d Paul Mackerras       2013-09-20  348  	mutex_unlock(&vcpu->kvm->arch.hpt_mutex);
e71b2a39afff245 Alexander Graf       2009-10-30  349  
93b159b466bdc97 Paul Mackerras       2013-09-20  350  	if (!gpte->may_read || (iswrite && !gpte->may_write))
6ed1485f65f0eb1 Paul Mackerras       2013-06-22  351  		return -EPERM;
e71b2a39afff245 Alexander Graf       2009-10-30  352  	return 0;
e71b2a39afff245 Alexander Graf       2009-10-30  353  
e71b2a39afff245 Alexander Graf       2009-10-30  354  no_page_found:
9308ab8e2da933d Paul Mackerras       2013-09-20  355  	mutex_unlock(&vcpu->kvm->arch.hpt_mutex);
e71b2a39afff245 Alexander Graf       2009-10-30  356  	return -ENOENT;
e71b2a39afff245 Alexander Graf       2009-10-30  357  
e71b2a39afff245 Alexander Graf       2009-10-30  358  no_seg_found:
e71b2a39afff245 Alexander Graf       2009-10-30  359  	dprintk("KVM MMU: Trigger segment fault\n");
e71b2a39afff245 Alexander Graf       2009-10-30  360  	return -EINVAL;
e71b2a39afff245 Alexander Graf       2009-10-30  361  }
e71b2a39afff245 Alexander Graf       2009-10-30  362  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-06  4:11 [PATCH] KVM: Change [g|h]va_t as u64 Anshuman Khandual
                   ` (3 preceding siblings ...)
  2026-03-06 15:30 ` kernel test robot
@ 2026-03-06 18:16 ` Sean Christopherson
  2026-03-08 12:58   ` Anshuman Khandual
  4 siblings, 1 reply; 11+ messages in thread
From: Sean Christopherson @ 2026-03-06 18:16 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: linux-kernel, Paolo Bonzini, kvm

On Fri, Mar 06, 2026, Anshuman Khandual wrote:
> Change both [g|h]va_t as u64 to be consistent with other address types.

That's hilariously, blatantly wrong.

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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-06 18:16 ` Sean Christopherson
@ 2026-03-08 12:58   ` Anshuman Khandual
  2026-03-08 13:35     ` Anshuman Khandual
  2026-03-09  8:20     ` Paolo Bonzini
  0 siblings, 2 replies; 11+ messages in thread
From: Anshuman Khandual @ 2026-03-08 12:58 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: linux-kernel, Paolo Bonzini, kvm

On 06/03/26 11:46 PM, Sean Christopherson wrote:
> On Fri, Mar 06, 2026, Anshuman Khandual wrote:
>> Change both [g|h]va_t as u64 to be consistent with other address types.
> 
> That's hilariously, blatantly wrong.

Sorry did not understand how this is wrong. Both guest and host
virtual address types should be be contained in u64 rather than
'unsigned long'. Did I miss something else here.

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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-08 12:58   ` Anshuman Khandual
@ 2026-03-08 13:35     ` Anshuman Khandual
  2026-03-09  8:20     ` Paolo Bonzini
  1 sibling, 0 replies; 11+ messages in thread
From: Anshuman Khandual @ 2026-03-08 13:35 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: linux-kernel, Paolo Bonzini, kvm



On 08/03/26 6:28 PM, Anshuman Khandual wrote:
> On 06/03/26 11:46 PM, Sean Christopherson wrote:
>> On Fri, Mar 06, 2026, Anshuman Khandual wrote:
>>> Change both [g|h]va_t as u64 to be consistent with other address types.
>>
>> That's hilariously, blatantly wrong.
> 
> Sorry did not understand how this is wrong. Both guest and host
> virtual address types should be be contained in u64 rather than
> 'unsigned long'. Did I miss something else here.

Is this about 32 bit systems where unsigned long would have matched
a 32 bit pointer size where as u64 will not ? But would not the u64
still contain 32 bit pointer without any issues.


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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-08 12:58   ` Anshuman Khandual
  2026-03-08 13:35     ` Anshuman Khandual
@ 2026-03-09  8:20     ` Paolo Bonzini
  2026-03-09  8:29       ` Anshuman Khandual
  1 sibling, 1 reply; 11+ messages in thread
From: Paolo Bonzini @ 2026-03-09  8:20 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: Sean Christopherson, Kernel Mailing List, Linux, kvm

Il dom 8 mar 2026, 13:58 Anshuman Khandual <anshuman.khandual@arm.com>
ha scritto:
>
> On 06/03/26 11:46 PM, Sean Christopherson wrote:
> > On Fri, Mar 06, 2026, Anshuman Khandual wrote:
> >> Change both [g|h]va_t as u64 to be consistent with other address types.
> >
> > That's hilariously, blatantly wrong.
>
> Sorry did not understand how this is wrong. Both guest and host
> virtual address types should be be contained in u64 rather than
> 'unsigned long'. Did I miss something else here.

Virtual addresses are pointers and the pointer-sized integer type in
Linux is long.

You also didn't try compiling it on any architecture where this patch
would have made a difference.

Paolo

>


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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-09  8:20     ` Paolo Bonzini
@ 2026-03-09  8:29       ` Anshuman Khandual
  2026-03-09  8:31         ` Paolo Bonzini
  0 siblings, 1 reply; 11+ messages in thread
From: Anshuman Khandual @ 2026-03-09  8:29 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Sean Christopherson, Kernel Mailing List, Linux, kvm

On 09/03/26 1:50 PM, Paolo Bonzini wrote:
> Il dom 8 mar 2026, 13:58 Anshuman Khandual <anshuman.khandual@arm.com>
> ha scritto:
>>
>> On 06/03/26 11:46 PM, Sean Christopherson wrote:
>>> On Fri, Mar 06, 2026, Anshuman Khandual wrote:
>>>> Change both [g|h]va_t as u64 to be consistent with other address types.
>>>
>>> That's hilariously, blatantly wrong.
>>
>> Sorry did not understand how this is wrong. Both guest and host
>> virtual address types should be be contained in u64 rather than
>> 'unsigned long'. Did I miss something else here.
> 
> Virtual addresses are pointers and the pointer-sized integer type in
> Linux is long.

Agreed but would not u64 work as well ? OR will it be over provisioning
causing memory wastage for all those unused higher 32 bits on platforms
where long is just 32 bits.

> > You also didn't try compiling it on any architecture where this patch
> would have made a difference.

Right, had missed those. But have fixed all the reported places on x86
and powerpc platforms now.

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

* Re: [PATCH] KVM: Change [g|h]va_t as u64
  2026-03-09  8:29       ` Anshuman Khandual
@ 2026-03-09  8:31         ` Paolo Bonzini
  0 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2026-03-09  8:31 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: Sean Christopherson, Kernel Mailing List, Linux, kvm

On Mon, Mar 9, 2026 at 9:29 AM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> On 09/03/26 1:50 PM, Paolo Bonzini wrote:
> > Il dom 8 mar 2026, 13:58 Anshuman Khandual <anshuman.khandual@arm.com>
> > ha scritto:
> >>
> >> On 06/03/26 11:46 PM, Sean Christopherson wrote:
> >>> On Fri, Mar 06, 2026, Anshuman Khandual wrote:
> >>>> Change both [g|h]va_t as u64 to be consistent with other address types.
> >>>
> >>> That's hilariously, blatantly wrong.
> >>
> >> Sorry did not understand how this is wrong. Both guest and host
> >> virtual address types should be be contained in u64 rather than
> >> 'unsigned long'. Did I miss something else here.
> >
> > Virtual addresses are pointers and the pointer-sized integer type in
> > Linux is long.
>
> Agreed but would not u64 work as well ? OR will it be over provisioning
> causing memory wastage for all those unused higher 32 bits on platforms
> where long is just 32 bits.

Maybe, but you'd have to add casts which makes the code harder to
follow and more brittle. So that's not a good idea.

Also, even on 64-bit systems any %l printk format have to be changed to %ll.

Paolo


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

end of thread, other threads:[~2026-03-09  8:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-06  4:11 [PATCH] KVM: Change [g|h]va_t as u64 Anshuman Khandual
2026-03-06  9:55 ` kernel test robot
2026-03-06 10:26 ` kernel test robot
2026-03-06 13:48 ` kernel test robot
2026-03-06 15:30 ` kernel test robot
2026-03-06 18:16 ` Sean Christopherson
2026-03-08 12:58   ` Anshuman Khandual
2026-03-08 13:35     ` Anshuman Khandual
2026-03-09  8:20     ` Paolo Bonzini
2026-03-09  8:29       ` Anshuman Khandual
2026-03-09  8:31         ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox