[PATCH] KVM: allow NULL writable argument to __kvm_faultin_pfn

2025-01-11 Thread Christian Zigotzky



> On 06 January 2025 at 07:57 pm, Sean Christopherson  wrote:
> 
> On Wed, Jan 01, 2025, Paolo Bonzini wrote:
>> kvm_follow_pfn() is able to work with NULL in the .map_writable field
>> of the homonymous struct.  But __kvm_faultin_pfn() rejects the combo
>> despite KVM for e500 trying to use it.  Indeed .map_writable is not
>> particularly useful if the flags include FOLL_WRITE and readonly
>> guest memory is not supported, so add support to __kvm_faultin_pfn()
>> for this case.
> 
> I would prefer to keep the sanity check to minimize the risk of a page fault
> handler not supporting opportunistic write mappings.  e500 is definitely the
> odd one out here.
> 
> What about adding a dedicated wrapper for getting a writable PFN?  E.g. 
> (untested)
> 
> ---
> arch/powerpc/kvm/e500_mmu_host.c | 2 +-
> arch/x86/kvm/vmx/vmx.c   | 3 +--
> include/linux/kvm_host.h | 8 
> 3 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/e500_mmu_host.c 
> b/arch/powerpc/kvm/e500_mmu_host.c
> index e5a145b578a4..2251bb30b8ec 100644
> --- a/arch/powerpc/kvm/e500_mmu_host.c
> +++ b/arch/powerpc/kvm/e500_mmu_host.c
> @@ -444,7 +444,7 @@ static inline int kvmppc_e500_shadow_map(struct 
> kvmppc_vcpu_e500 *vcpu_e500,
> 
>if (likely(!pfnmap)) {
>tsize_pages = 1UL << (tsize + 10 - PAGE_SHIFT);
> -pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page);
> +pfn = kvm_faultin_writable_pfn(slot, gfn, &page);
>if (is_error_noslot_pfn(pfn)) {
>if (printk_ratelimit())
>pr_err("%s: real page not found for gfn %lx\n",
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 893366e53732..7012b583f2e8 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6800,7 +6800,6 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu 
> *vcpu)
>struct page *refcounted_page;
>unsigned long mmu_seq;
>kvm_pfn_t pfn;
> -bool writable;
> 
>/* Defer reload until vmcs01 is the current VMCS. */
>if (is_guest_mode(vcpu)) {
> @@ -6836,7 +6835,7 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu 
> *vcpu)
> * controls the APIC-access page memslot, and only deletes the memslot
> * if APICv is permanently inhibited, i.e. the memslot won't reappear.
> */
> -pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, 
> &refcounted_page);
> +pfn = kvm_faultin_writable_pfn(slot, gfn, &refcounted_page);
>if (is_error_noslot_pfn(pfn))
>return;
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index c788d0bd952a..b0af7c7f99da 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1287,6 +1287,14 @@ static inline kvm_pfn_t kvm_faultin_pfn(struct 
> kvm_vcpu *vcpu, gfn_t gfn,
> write ? FOLL_WRITE : 0, writable, refcounted_page);
> }
> 
> +static inline kvm_pfn_t kvm_faultin_writable_pfn(const struct 
> kvm_memory_slot *slot,
> + gfn_t gfn, struct page **refcounted_page)
> +{
> +bool writable;
> +
> +return __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, 
> refcounted_page);
> +}
> +
> int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
>int len);
> int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
> 
> base-commit: 2c3412e999738bfd60859c493ff47f5c268814a3
> --

This patch works. Tested-by: Christian Zigotzky 

Thanks



Re: [PATCH] powerpc/64s: Rewrite __real_pte() as a static inline

2025-01-11 Thread IBM
Christophe Leroy  writes:

> Rewrite __real_pte() as a static inline in order to avoid
> following warning/error when building with 4k page size:
>
> CC  arch/powerpc/mm/book3s64/hash_tlb.o
>   arch/powerpc/mm/book3s64/hash_tlb.c: In function 'hpte_need_flush':
>   arch/powerpc/mm/book3s64/hash_tlb.c:49:16: error: variable 'offset' set 
> but not used [-Werror=unused-but-set-variable]
>  49 | int i, offset;
> |^~
>   cc1: all warnings being treated as errors
>
> Reported-by: kernel test robot 
> Closes: 
> https://lore.kernel.org/oe-kbuild-all/202501081741.ayfwybsq-...@intel.com/

Great. Why not fix the other warning as well which is reported in above
link, which is...  

--
   arch/powerpc/mm/book3s64/hash_native.c: In function 
'native_flush_hash_range':
>> arch/powerpc/mm/book3s64/hash_native.c:786:29: warning: variable 'index' set 
>> but not used [-Wunused-but-set-variable]
 786 | unsigned long hash, index, hidx, shift, slot;
--

...similar to how we fixed this warning by making the macro as static
inline? That means something like this (not tested)?

-#define __rpte_to_hidx(r,index)(pte_val(__rpte_to_pte(r)) >> 
H_PAGE_F_GIX_SHIFT)
+static inline unsigned long __rpte_to_hidx(real_pte_t r, unsigned long index)
+{
+   return pte_val(__rpte_to_pte(r)) >> H_PAGE_F_GIX_SHIFT;
+}


-ritesh


> Fixes: ff31e105464d ("powerpc/mm/hash64: Store the slot information at the 
> right offset for hugetlb")
> Signed-off-by: Christophe Leroy 
> ---
>  arch/powerpc/include/asm/book3s/64/hash-4k.h | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h 
> b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> index c3efacab4b94..a7a68ba9c71b 100644
> --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
> +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> @@ -77,7 +77,10 @@
>  /*
>   * With 4K page size the real_pte machinery is all nops.
>   */
> -#define __real_pte(e, p, o)  ((real_pte_t){(e)})
> +static inline real_pte_t __real_pte(pte_t pte, pte_t *ptep, int offset)
> +{
> + return (real_pte_t){pte};
> +}
>  #define __rpte_to_pte(r) ((r).pte)
>  #define __rpte_to_hidx(r,index)  (pte_val(__rpte_to_pte(r)) >> 
> H_PAGE_F_GIX_SHIFT)
>  
> -- 
> 2.47.0



Re: [PATCH] arch/powerpc: Remove unused function icp_native_cause_ipi_rm()

2025-01-11 Thread Ritesh Harjani (IBM)
Gautam Menghani  writes:

> Remove icp_native_cause_ipi_rm() as it has no callers since
> commit 53af3ba2e819("KVM: PPC: Book3S HV: Allow guest exit path to have
> MMU on")
>
> Signed-off-by: Gautam Menghani 
> ---
>  arch/powerpc/include/asm/xics.h   |  1 -
>  arch/powerpc/sysdev/xics/icp-native.c | 21 -
>  2 files changed, 22 deletions(-)

Indeed there are no callers left of this function. Great catch!

Looks good to me. Please feel free to add - 
Reviewed-by: Ritesh Harjani (IBM) 

-ritesh



Re: [PATCH 3/5] KVM: Add a common kvm_run flag to communicate an exit needs completion

2025-01-11 Thread Marc Zyngier
On Sat, 11 Jan 2025 01:24:48 +,
Sean Christopherson  wrote:
> 
> Add a kvm_run flag, KVM_RUN_NEEDS_COMPLETION, to communicate to userspace
> that KVM_RUN needs to be re-executed prior to save/restore in order to
> complete the instruction/operation that triggered the userspace exit.
> 
> KVM's current approach of adding notes in the Documentation is beyond
> brittle, e.g. there is at least one known case where a KVM developer added
> a new userspace exit type, and then that same developer forgot to handle
> completion when adding userspace support.

Is this going to fix anything? If they couldn't be bothered to read
the documentation, let alone update it, how is that going to be
improved by extra rules and regulations?

I don't see how someone ignoring the documented behaviour of a given
exit reason is, all of a sudden, have an epiphany and take a *new*
flag into account.

> 
> On x86, there are multiple exits that need completion, but they are all
> conveniently funneled through a single callback, i.e. in theory, this is a
> one-time thing for KVM x86 (and other architectures could follow suit with
> additional refactoring).
> 
> Signed-off-by: Sean Christopherson 
> ---
>  Documentation/virt/kvm/api.rst| 48 ++-
>  arch/powerpc/kvm/book3s_emulate.c |  1 +
>  arch/powerpc/kvm/book3s_hv.c  |  1 +
>  arch/powerpc/kvm/book3s_pr.c  |  2 ++
>  arch/powerpc/kvm/booke.c  |  1 +
>  arch/x86/include/uapi/asm/kvm.h   |  7 +++--
>  arch/x86/kvm/x86.c|  2 ++
>  include/uapi/linux/kvm.h  |  3 ++
>  virt/kvm/kvm_main.c   |  1 +
>  9 files changed, 49 insertions(+), 17 deletions(-)
> 
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index c92c8d4e8779..8e172675d8d6 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -6505,7 +6505,7 @@ local APIC is not used.
>  
>   __u16 flags;
>  
> -More architecture-specific flags detailing state of the VCPU that may
> +Common and architecture-specific flags detailing state of the VCPU that may
>  affect the device's behavior. Current defined flags::
>  
>/* x86, set if the VCPU is in system management mode */
> @@ -6518,6 +6518,8 @@ affect the device's behavior. Current defined flags::
>/* arm64, set for KVM_EXIT_DEBUG */
>#define KVM_DEBUG_ARCH_HSR_HIGH_VALID  (1 << 0)
>  
> +  /* all architectures, set when the exit needs completion (via KVM_RUN) */
> +  #define KVM_RUN_NEEDS_COMPLETION  (1 << 15)
>  ::
>  
>   /* in (pre_kvm_run), out (post_kvm_run) */
> @@ -6632,19 +6634,10 @@ requires a guest to interact with host userspace.
>  
>  .. note::
>  
> -  For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR, 
> KVM_EXIT_XEN,
> -  KVM_EXIT_EPR, KVM_EXIT_X86_RDMSR, KVM_EXIT_X86_WRMSR, and 
> KVM_EXIT_HYPERCALL
> -  the corresponding operations are complete (and guest state is 
> consistent)
> -  only after userspace has re-entered the kernel with KVM_RUN.  The 
> kernel
> -  side will first finish incomplete operations and then check for pending
> -  signals.
> +  For some exits, userspace must re-enter the kernel with KVM_RUN to
> +  complete the exit and ensure guest state is consistent.
>  
> -  The pending state of the operation is not preserved in state which is
> -  visible to userspace, thus userspace should ensure that the operation 
> is
> -  completed before performing a live migration.  Userspace can re-enter 
> the
> -  guest with an unmasked signal pending or with the immediate_exit field 
> set
> -  to complete pending operations without allowing any further 
> instructions
> -  to be executed.
> +  See KVM_CAP_NEEDS_COMPLETION for details.
>  
>  ::
>  
> @@ -8239,7 +8232,7 @@ Note: Userspace is responsible for correctly 
> configuring CPUID 0x15, a.k.a. the
>  core crystal clock frequency, if a non-zero CPUID 0x15 is exposed to the 
> guest.
>  
>  7.36 KVM_CAP_X86_GUEST_MODE
> ---
> +---
>  
>  :Architectures: x86
>  :Returns: Informational only, -EINVAL on direct KVM_ENABLE_CAP.
> @@ -8252,6 +8245,33 @@ KVM exits with the register state of either the L1 or 
> L2 guest
>  depending on which executed at the time of an exit. Userspace must
>  take care to differentiate between these cases.
>  
> +7.37 KVM_CAP_NEEDS_COMPLETION
> +-
> +
> +:Architectures: all
> +:Returns: Informational only, -EINVAL on direct KVM_ENABLE_CAP.
> +
> +The presence of this capability indicates that KVM_RUN will set
> +KVM_RUN_NEEDS_COMPLETION in kvm_run.flags if KVM requires userspace to 
> re-enter
> +the kernel KVM_RUN to complete the exit.
> +
> +For select exits, userspace must re-enter the kernel with KVM_RUN to complete
> +the corresponding operation, only after which is guest state guaranteed to be
> +consistent.  On such a KVM_RUN, the kernel side will first finish 

Re: [PATCH] fs: introduce getfsxattrat and setfsxattrat syscalls

2025-01-11 Thread kernel test robot
Hi Andrey,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brauner-vfs/vfs.all]
[also build test WARNING on geert-m68k/for-next powerpc/next powerpc/fixes 
s390/features linus/master v6.13-rc6 next-20250110]
[cannot apply to geert-m68k/for-linus deller-parisc/for-next 
jcmvbkbc-xtensa/xtensa-for-next arnd-asm-generic/master tip/x86/asm]
[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/Andrey-Albershteyn/fs-introduce-getfsxattrat-and-setfsxattrat-syscalls/20250110-014739
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:
https://lore.kernel.org/r/20250109174540.893098-1-aalbersh%40kernel.org
patch subject: [PATCH] fs: introduce getfsxattrat and setfsxattrat syscalls
config: arm-allnoconfig 
(https://download.01.org/0day-ci/archive/20250111/202501112052.zjevfjhd-...@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 
6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20250111/202501112052.zjevfjhd-...@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 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202501112052.zjevfjhd-...@intel.com/

All warnings (new ones prefixed by >>):

>> :1615:2: warning: syscall getfsxattrat not implemented [-W#warnings]
1615 | #warning syscall getfsxattrat not implemented
 |  ^
>> :1618:2: warning: syscall setfsxattrat not implemented [-W#warnings]
1618 | #warning syscall setfsxattrat not implemented
 |  ^
   2 warnings generated.
--
>> :1615:2: warning: syscall getfsxattrat not implemented [-W#warnings]
1615 | #warning syscall getfsxattrat not implemented
 |  ^
>> :1618:2: warning: syscall setfsxattrat not implemented [-W#warnings]
1618 | #warning syscall setfsxattrat not implemented
 |  ^
   2 warnings generated.

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



Re: [PATCH v6 24/26] mm: Remove devmap related functions and page table bits

2025-01-11 Thread Huacai Chen
Hi, Alistair,

I think the last two patches can be squashed into this one.


Huacai

On Fri, Jan 10, 2025 at 2:03 PM Alistair Popple  wrote:
>
> Now that DAX and all other reference counts to ZONE_DEVICE pages are
> managed normally there is no need for the special devmap PTE/PMD/PUD
> page table bits. So drop all references to these, freeing up a
> software defined page table bit on architectures supporting it.
>
> Signed-off-by: Alistair Popple 
> Acked-by: Will Deacon  # arm64
> ---
>  Documentation/mm/arch_pgtable_helpers.rst |  6 +--
>  arch/arm64/Kconfig|  1 +-
>  arch/arm64/include/asm/pgtable-prot.h |  1 +-
>  arch/arm64/include/asm/pgtable.h  | 24 +
>  arch/powerpc/Kconfig  |  1 +-
>  arch/powerpc/include/asm/book3s/64/hash-4k.h  |  6 +--
>  arch/powerpc/include/asm/book3s/64/hash-64k.h |  7 +--
>  arch/powerpc/include/asm/book3s/64/pgtable.h  | 53 +--
>  arch/powerpc/include/asm/book3s/64/radix.h| 14 +-
>  arch/x86/Kconfig  |  1 +-
>  arch/x86/include/asm/pgtable.h| 51 +-
>  arch/x86/include/asm/pgtable_types.h  |  5 +--
>  include/linux/mm.h|  7 +--
>  include/linux/pfn_t.h | 20 +---
>  include/linux/pgtable.h   | 19 +--
>  mm/Kconfig|  4 +-
>  mm/debug_vm_pgtable.c | 59 +
>  mm/hmm.c  |  3 +-
>  18 files changed, 11 insertions(+), 271 deletions(-)
>
> diff --git a/Documentation/mm/arch_pgtable_helpers.rst 
> b/Documentation/mm/arch_pgtable_helpers.rst
> index af24516..c88c7fa 100644
> --- a/Documentation/mm/arch_pgtable_helpers.rst
> +++ b/Documentation/mm/arch_pgtable_helpers.rst
> @@ -30,8 +30,6 @@ PTE Page Table Helpers
>  
> +---+--+
>  | pte_protnone  | Tests a PROT_NONE PTE  
>   |
>  
> +---+--+
> -| pte_devmap| Tests a ZONE_DEVICE mapped PTE 
>   |
> -+---+--+
>  | pte_soft_dirty| Tests a soft dirty PTE 
>   |
>  
> +---+--+
>  | pte_swp_soft_dirty| Tests a soft dirty swapped PTE 
>   |
> @@ -104,8 +102,6 @@ PMD Page Table Helpers
>  
> +---+--+
>  | pmd_protnone  | Tests a PROT_NONE PMD  
>   |
>  
> +---+--+
> -| pmd_devmap| Tests a ZONE_DEVICE mapped PMD 
>   |
> -+---+--+
>  | pmd_soft_dirty| Tests a soft dirty PMD 
>   |
>  
> +---+--+
>  | pmd_swp_soft_dirty| Tests a soft dirty swapped PMD 
>   |
> @@ -177,8 +173,6 @@ PUD Page Table Helpers
>  
> +---+--+
>  | pud_write | Tests a writable PUD   
>   |
>  
> +---+--+
> -| pud_devmap| Tests a ZONE_DEVICE mapped PUD 
>   |
> -+---+--+
>  | pud_mkyoung   | Creates a young PUD
>   |
>  
> +---+--+
>  | pud_mkold | Creates an old PUD 
>   |
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 39310a4..81855d1 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -41,7 +41,6 @@ config ARM64
> select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
> select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
> select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAFT
> -   select ARCH_HAS_PTE_DEVMAP
> select ARCH_HAS_PTE_SPECIAL
> select ARCH_HAS_HW_PTE_YOUNG
> select ARCH_HAS_SETUP_DMA_OPS
> diff --git a/arch/arm64/include/asm/pgtable-prot.h 
> b/arch/arm64/include/asm/pgtable-prot.h
> index 9f9cf13..49b51df 100644
> --- a/arch/arm64/include/asm/pgtable-prot.h
> +++ b/arch/arm64/include/asm/pgtable-prot.h
> @@ -17,7 +17,6 @@
>  #define PTE_SWP_EXCLUSIVE  (_AT(pteval_t, 1) << 2)  /* only for swp ptes 
> */
>  #define PTE_DIRTY  (_AT(pteval_t, 1) << 55)
>  #define PTE_SPECIAL

[powerpc:next-test] BUILD SUCCESS 2bf66e66d2e6feece6175ec09ec590a0a8563bdd

2025-01-11 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
next-test
branch HEAD: 2bf66e66d2e6feece6175ec09ec590a0a8563bdd  selftests/powerpc: Fix 
argument order to timer_sub()

elapsed time: 1310m

configs tested: 223
configs skipped: 6

The following configs have been built successfully.
More configs may be tested in the coming days.

tested configs:
alpha allnoconfiggcc-14.2.0
alphaallyesconfigclang-20
alphaallyesconfiggcc-14.2.0
alpha   defconfiggcc-14.1.0
alpha   defconfiggcc-14.2.0
arc  allmodconfigclang-18
arc  allmodconfiggcc-13.2.0
arc   allnoconfiggcc-13.2.0
arc   allnoconfiggcc-14.2.0
arc  allyesconfigclang-18
arc  allyesconfiggcc-13.2.0
arc defconfiggcc-14.2.0
arc   randconfig-001-20250111gcc-13.2.0
arc   randconfig-002-20250111gcc-13.2.0
arm  allmodconfigclang-18
arm  allmodconfiggcc-14.2.0
arm   allnoconfigclang-17
arm   allnoconfiggcc-14.2.0
arm  allyesconfigclang-18
arm  allyesconfiggcc-14.2.0
arm defconfiggcc-14.2.0
armmps2_defconfigclang-15
arm   randconfig-001-20250111clang-16
arm   randconfig-002-20250111gcc-14.2.0
arm   randconfig-003-20250111clang-20
arm   randconfig-004-20250111clang-20
arm   sama5_defconfigclang-15
arm   sunxi_defconfiggcc-14.1.0
arm wpcm450_defconfiggcc-14.1.0
arm64allmodconfigclang-18
arm64 allnoconfiggcc-14.2.0
arm64   defconfiggcc-14.2.0
arm64 randconfig-001-20250111gcc-14.2.0
arm64 randconfig-002-20250111clang-20
arm64 randconfig-003-20250111clang-18
arm64 randconfig-004-20250111clang-16
csky  allnoconfiggcc-14.2.0
cskydefconfiggcc-14.2.0
csky  randconfig-001-20250111gcc-14.2.0
csky  randconfig-001-20250112gcc-14.2.0
csky  randconfig-002-20250111gcc-14.2.0
csky  randconfig-002-20250112gcc-14.2.0
hexagon  allmodconfigclang-20
hexagon   allnoconfigclang-20
hexagon   allnoconfiggcc-14.2.0
hexagon  allyesconfigclang-18
hexagon  allyesconfigclang-20
hexagon defconfiggcc-14.2.0
hexagon   randconfig-001-20250111clang-20
hexagon   randconfig-001-20250112gcc-14.2.0
hexagon   randconfig-002-20250111clang-15
hexagon   randconfig-002-20250112gcc-14.2.0
i386 allmodconfigclang-19
i386 allmodconfiggcc-12
i386  allnoconfigclang-19
i386  allnoconfiggcc-12
i386 allyesconfigclang-19
i386 allyesconfiggcc-12
i386buildonly-randconfig-001-20250111gcc-12
i386buildonly-randconfig-001-20250112clang-19
i386buildonly-randconfig-002-20250111gcc-11
i386buildonly-randconfig-002-20250112clang-19
i386buildonly-randconfig-003-20250111gcc-12
i386buildonly-randconfig-003-20250112clang-19
i386buildonly-randconfig-004-20250111gcc-12
i386buildonly-randconfig-004-20250112clang-19
i386buildonly-randconfig-005-20250111gcc-12
i386buildonly-randconfig-005-20250112clang-19
i386buildonly-randconfig-006-20250111clang-19
i386buildonly-randconfig-006-20250112clang-19
i386defconfigclang-19
i386  randconfig-001-20250112clang-19
i386  randconfig-002-20250112clang-19
i386  randconfig-003-20250112clang-19
i386  randconfig-004-20250112clang-19
i386  randconfig-005-20250112clang-19
i386  randconfig-006-20250112clang-19
i386  randconfig-007-20250112clang-19
i386  randconfig-011-20250112

[PATCH] KVM: allow NULL writable argument to __kvm_faultin_pfn

2025-01-11 Thread Christian Zigotzky


> On 06 January 2025 at 07:57 pm, Sean Christopherson  wrote:
> 
> On Wed, Jan 01, 2025, Paolo Bonzini wrote:
>> kvm_follow_pfn() is able to work with NULL in the .map_writable field
>> of the homonymous struct.  But __kvm_faultin_pfn() rejects the combo
>> despite KVM for e500 trying to use it.  Indeed .map_writable is not
>> particularly useful if the flags include FOLL_WRITE and readonly
>> guest memory is not supported, so add support to __kvm_faultin_pfn()
>> for this case.
> 
> I would prefer to keep the sanity check to minimize the risk of a page fault
> handler not supporting opportunistic write mappings.  e500 is definitely the
> odd one out here.
> 
> What about adding a dedicated wrapper for getting a writable PFN?  E.g. 
> (untested)
> 
> ---
> arch/powerpc/kvm/e500_mmu_host.c | 2 +-
> arch/x86/kvm/vmx/vmx.c   | 3 +--
> include/linux/kvm_host.h | 8 
> 3 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/e500_mmu_host.c 
> b/arch/powerpc/kvm/e500_mmu_host.c
> index e5a145b578a4..2251bb30b8ec 100644
> --- a/arch/powerpc/kvm/e500_mmu_host.c
> +++ b/arch/powerpc/kvm/e500_mmu_host.c
> @@ -444,7 +444,7 @@ static inline int kvmppc_e500_shadow_map(struct 
> kvmppc_vcpu_e500 *vcpu_e500,
> 
>   if (likely(!pfnmap)) {
>   tsize_pages = 1UL << (tsize + 10 - PAGE_SHIFT);
> -pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page);
> +pfn = kvm_faultin_writable_pfn(slot, gfn, &page);
>   if (is_error_noslot_pfn(pfn)) {
>   if (printk_ratelimit())
>   pr_err("%s: real page not found for gfn %lx\n",
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 893366e53732..7012b583f2e8 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6800,7 +6800,6 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu 
> *vcpu)
>   struct page *refcounted_page;
>   unsigned long mmu_seq;
>   kvm_pfn_t pfn;
> -bool writable;
> 
>   /* Defer reload until vmcs01 is the current VMCS. */
>   if (is_guest_mode(vcpu)) {
> @@ -6836,7 +6835,7 @@ void vmx_set_apic_access_page_addr(struct kvm_vcpu 
> *vcpu)
>* controls the APIC-access page memslot, and only deletes the memslot
>* if APICv is permanently inhibited, i.e. the memslot won't reappear.
>*/
> -pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, 
> &refcounted_page);
> +pfn = kvm_faultin_writable_pfn(slot, gfn, &refcounted_page);
>   if (is_error_noslot_pfn(pfn))
>   return;
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index c788d0bd952a..b0af7c7f99da 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1287,6 +1287,14 @@ static inline kvm_pfn_t kvm_faultin_pfn(struct 
> kvm_vcpu *vcpu, gfn_t gfn,
>write ? FOLL_WRITE : 0, writable, refcounted_page);
> }
> 
> +static inline kvm_pfn_t kvm_faultin_writable_pfn(const struct 
> kvm_memory_slot *slot,
> + gfn_t gfn, struct page **refcounted_page)
> +{
> +bool writable;
> +
> +return __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, 
> refcounted_page);
> +}
> +
> int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
>   int len);
> int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
> 
> base-commit: 2c3412e999738bfd60859c493ff47f5c268814a3
> --

This patch works. Tested-by: Christian Zigotzky 

Thanks



Re: [PATCH] fs: introduce getfsxattrat and setfsxattrat syscalls

2025-01-11 Thread kernel test robot
Hi Andrey,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brauner-vfs/vfs.all]
[also build test WARNING on geert-m68k/for-next powerpc/next powerpc/fixes 
s390/features linus/master v6.13-rc6 next-20250110]
[cannot apply to geert-m68k/for-linus deller-parisc/for-next 
jcmvbkbc-xtensa/xtensa-for-next arnd-asm-generic/master tip/x86/asm]
[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/Andrey-Albershteyn/fs-introduce-getfsxattrat-and-setfsxattrat-syscalls/20250110-014739
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:
https://lore.kernel.org/r/20250109174540.893098-1-aalbersh%40kernel.org
patch subject: [PATCH] fs: introduce getfsxattrat and setfsxattrat syscalls
config: s390-randconfig-r133-20250111 
(https://download.01.org/0day-ci/archive/20250111/202501112305.epqr5jnx-...@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.2.0
reproduce: 
(https://download.01.org/0day-ci/archive/20250111/202501112305.epqr5jnx-...@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 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202501112305.epqr5jnx-...@intel.com/

sparse warnings: (new ones prefixed by >>)
   fs/inode.c:605:28: sparse: sparse: context imbalance in 
'inode_wait_for_lru_isolating' - unexpected unlock
   fs/inode.c: note: in included file (through include/linux/wait.h, 
include/linux/wait_bit.h, include/linux/fs.h):
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates 
to true
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates 
to true
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates 
to true
   fs/inode.c:999:28: sparse: sparse: context imbalance in 'inode_lru_isolate' 
- unexpected unlock
   fs/inode.c:1058:9: sparse: sparse: context imbalance in 'find_inode' - 
different lock contexts for basic block
   fs/inode.c:1099:9: sparse: sparse: context imbalance in 'find_inode_fast' - 
different lock contexts for basic block
   fs/inode.c:1829:5: sparse: sparse: context imbalance in 
'insert_inode_locked' - wrong count at exit
   fs/inode.c:1947:20: sparse: sparse: context imbalance in 'iput_final' - 
unexpected unlock
   fs/inode.c:1961:6: sparse: sparse: context imbalance in 'iput' - wrong count 
at exit
   fs/inode.c:2494:17: sparse: sparse: context imbalance in 
'__wait_on_freeing_inode' - unexpected unlock
>> fs/inode.c:2960:1: sparse: sparse: Using plain integer as NULL pointer
>> fs/inode.c:2960:1: sparse: sparse: Using plain integer as NULL pointer
>> fs/inode.c:2960:1: sparse: sparse: Using plain integer as NULL pointer
>> fs/inode.c:2960:1: sparse: sparse: Using plain integer as NULL pointer
   fs/inode.c:2998:39: sparse: sparse: incorrect type in argument 2 (different 
address spaces) @@ expected struct fsxattr [noderef] __user *ufa @@ got 
struct fsxattr *fsx @@
   fs/inode.c:2998:39: sparse: expected struct fsxattr [noderef] __user *ufa
   fs/inode.c:2998:39: sparse: got struct fsxattr *fsx
   fs/inode.c:2998:39: sparse: sparse: incorrect type in argument 2 (different 
address spaces) @@ expected struct fsxattr [noderef] __user *ufa @@ got 
struct fsxattr *fsx @@
   fs/inode.c:2998:39: sparse: expected struct fsxattr [noderef] __user *ufa
   fs/inode.c:2998:39: sparse: got struct fsxattr *fsx
   fs/inode.c:3008:1: sparse: sparse: Using plain integer as NULL pointer
   fs/inode.c:3008:1: sparse: sparse: Using plain integer as NULL pointer
   fs/inode.c:3008:1: sparse: sparse: Using plain integer as NULL pointer
   fs/inode.c:3008:1: sparse: sparse: Using plain integer as NULL pointer
   fs/inode.c:3032:41: sparse: sparse: incorrect type in argument 2 (different 
address spaces) @@ expected struct fsxattr [noderef] __user *ufa @@ got 
struct fsxattr *fsx @@
   fs/inode.c:3032:41: sparse: expected struct fsxattr [noderef] __user *ufa
   fs/inode.c:3032:41: sparse: got struct fsxattr *fsx
   fs/inode.c:3032:41: sparse: sparse: incorrect type in argument 2 (different 
address spaces) @@ expected struct fsxattr [noderef] __user *ufa @@ got 
struct fsxattr *fsx @@
   fs/inode.c:3032:41: sparse: expected struct fsxattr [noderef] __user *ufa
   fs/inode.c:3032:41: sparse: got struct fsxattr *fsx

vim +2960 fs/inode.c

  2959  
> 2960  SYSCALL_DEFINE4(getfsxattrat, int, dfd, const char __user *, filename,
  2961  struct fsxattr *, fsx, int, at_flags)
  2962  {
  2963  struct fd

Re: [PATCH] fs: introduce getfsxattrat and setfsxattrat syscalls

2025-01-11 Thread kernel test robot
Hi Andrey,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brauner-vfs/vfs.all]
[also build test WARNING on geert-m68k/for-next powerpc/next powerpc/fixes 
s390/features linus/master v6.13-rc6 next-20250110]
[cannot apply to geert-m68k/for-linus deller-parisc/for-next 
jcmvbkbc-xtensa/xtensa-for-next tip/x86/asm]
[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/Andrey-Albershteyn/fs-introduce-getfsxattrat-and-setfsxattrat-syscalls/20250110-014739
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:
https://lore.kernel.org/r/20250109174540.893098-1-aalbersh%40kernel.org
patch subject: [PATCH] fs: introduce getfsxattrat and setfsxattrat syscalls
config: riscv-randconfig-002-20250111 
(https://download.01.org/0day-ci/archive/20250112/202501120410.3zwwyxqy-...@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20250112/202501120410.3zwwyxqy-...@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 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202501120410.3zwwyxqy-...@intel.com/

All warnings (new ones prefixed by >>):

>> :1615:2: warning: #warning syscall getfsxattrat not implemented 
>> [-Wcpp]
>> :1618:2: warning: #warning syscall setfsxattrat not implemented 
>> [-Wcpp]
--
>> :1615:2: warning: #warning syscall getfsxattrat not implemented 
>> [-Wcpp]
>> :1618:2: warning: #warning syscall setfsxattrat not implemented 
>> [-Wcpp]
--
>> :1615:2: warning: #warning syscall getfsxattrat not implemented 
>> [-Wcpp]
>> :1618:2: warning: #warning syscall setfsxattrat not implemented 
>> [-Wcpp]

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