linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
@ 2021-07-07  4:13 Alexey Kardashevskiy
  2021-07-07 17:48 ` Fabiano Rosas
  2021-08-13  9:50 ` Alexey Kardashevskiy
  0 siblings, 2 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2021-07-07  4:13 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Alexey Kardashevskiy, linux-kernel, kvm-ppc, Paul Mackerras

Currently it is vm-$currentpid which works as long as there is just one
VM per the userspace (99.99% cases) but produces a bunch
of "debugfs: Directory 'vm16679' with parent 'kvm' already present!"
when syzkaller (syscall fuzzer) is running so only one VM is present in
the debugfs for a given process.

This changes the debugfs node to include the LPID which alone should be
system wide unique. This leaves the existing pid for the convenience of
matching the VM's debugfs with the running userspace process (QEMU).

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 arch/powerpc/kvm/book3s_hv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 1d1fcc290fca..0223ddc0eed0 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -5227,7 +5227,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
 	/*
 	 * Create a debugfs directory for the VM
 	 */
-	snprintf(buf, sizeof(buf), "vm%d", current->pid);
+	snprintf(buf, sizeof(buf), "vm%d-lp%ld", current->pid, lpid);
 	kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
 	kvmppc_mmu_debugfs_init(kvm);
 	if (radix_enabled())
-- 
2.30.2


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

* Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
  2021-07-07  4:13 [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename Alexey Kardashevskiy
@ 2021-07-07 17:48 ` Fabiano Rosas
  2021-07-08  2:22   ` Alexey Kardashevskiy
  2021-08-13  9:50 ` Alexey Kardashevskiy
  1 sibling, 1 reply; 8+ messages in thread
From: Fabiano Rosas @ 2021-07-07 17:48 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Alexey Kardashevskiy, linux-kernel, kvm-ppc, Paul Mackerras

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> Currently it is vm-$currentpid which works as long as there is just one
> VM per the userspace (99.99% cases) but produces a bunch
> of "debugfs: Directory 'vm16679' with parent 'kvm' already present!"
> when syzkaller (syscall fuzzer) is running so only one VM is present in
> the debugfs for a given process.
>
> This changes the debugfs node to include the LPID which alone should be
> system wide unique. This leaves the existing pid for the convenience of
> matching the VM's debugfs with the running userspace process (QEMU).
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>

> ---
>  arch/powerpc/kvm/book3s_hv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 1d1fcc290fca..0223ddc0eed0 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -5227,7 +5227,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
>  	/*
>  	 * Create a debugfs directory for the VM
>  	 */
> -	snprintf(buf, sizeof(buf), "vm%d", current->pid);
> +	snprintf(buf, sizeof(buf), "vm%d-lp%ld", current->pid, lpid);
>  	kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
>  	kvmppc_mmu_debugfs_init(kvm);
>  	if (radix_enabled())

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

* Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
  2021-07-07 17:48 ` Fabiano Rosas
@ 2021-07-08  2:22   ` Alexey Kardashevskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Alexey Kardashevskiy @ 2021-07-08  2:22 UTC (permalink / raw)
  To: Fabiano Rosas, linuxppc-dev; +Cc: linux-kernel, kvm-ppc, Paul Mackerras



On 08/07/2021 03:48, Fabiano Rosas wrote:
> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> 
>> Currently it is vm-$currentpid which works as long as there is just one
>> VM per the userspace (99.99% cases) but produces a bunch
>> of "debugfs: Directory 'vm16679' with parent 'kvm' already present!"
>> when syzkaller (syscall fuzzer) is running so only one VM is present in
>> the debugfs for a given process.
>>
>> This changes the debugfs node to include the LPID which alone should be
>> system wide unique. This leaves the existing pid for the convenience of
>> matching the VM's debugfs with the running userspace process (QEMU).
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>

thanks.

Strangely it also fixes a bunch of

BUG: unable to handle kernel NULL pointer dereference in corrupted
BUG: unable to handle kernel paging request in corrupted

I was having 3 of these for every hour of running syzkaller and not 
anymore with this patch.


> 
>> ---
>>   arch/powerpc/kvm/book3s_hv.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>> index 1d1fcc290fca..0223ddc0eed0 100644
>> --- a/arch/powerpc/kvm/book3s_hv.c
>> +++ b/arch/powerpc/kvm/book3s_hv.c
>> @@ -5227,7 +5227,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
>>   	/*
>>   	 * Create a debugfs directory for the VM
>>   	 */
>> -	snprintf(buf, sizeof(buf), "vm%d", current->pid);
>> +	snprintf(buf, sizeof(buf), "vm%d-lp%ld", current->pid, lpid);
>>   	kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
>>   	kvmppc_mmu_debugfs_init(kvm);
>>   	if (radix_enabled())

-- 
Alexey

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

* Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
  2021-07-07  4:13 [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename Alexey Kardashevskiy
  2021-07-07 17:48 ` Fabiano Rosas
@ 2021-08-13  9:50 ` Alexey Kardashevskiy
  2021-08-17 22:20   ` Fabiano Rosas
  1 sibling, 1 reply; 8+ messages in thread
From: Alexey Kardashevskiy @ 2021-08-13  9:50 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linux-kernel, kvm-ppc, linuxppc-dev



On 07/07/2021 14:13, Alexey Kardashevskiy wrote:
> Currently it is vm-$currentpid which works as long as there is just one
> VM per the userspace (99.99% cases) but produces a bunch
> of "debugfs: Directory 'vm16679' with parent 'kvm' already present!"
> when syzkaller (syscall fuzzer) is running so only one VM is present in
> the debugfs for a given process.
> 
> This changes the debugfs node to include the LPID which alone should be
> system wide unique. This leaves the existing pid for the convenience of
> matching the VM's debugfs with the running userspace process (QEMU).
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Looks like this is not enough as syzkaller still manages to cause the 
error message, I need more robust approach as in 
https://lore.kernel.org/patchwork/patch/1472025/  or   alternatively 
move this debugfs stuff under the platform-independent directory, how 
about that?


> ---
>   arch/powerpc/kvm/book3s_hv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 1d1fcc290fca..0223ddc0eed0 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -5227,7 +5227,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
>   	/*
>   	 * Create a debugfs directory for the VM
>   	 */
> -	snprintf(buf, sizeof(buf), "vm%d", current->pid);
> +	snprintf(buf, sizeof(buf), "vm%d-lp%ld", current->pid, lpid);
>   	kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
>   	kvmppc_mmu_debugfs_init(kvm);
>   	if (radix_enabled())
> 

-- 
Alexey

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

* Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
  2021-08-13  9:50 ` Alexey Kardashevskiy
@ 2021-08-17 22:20   ` Fabiano Rosas
  2021-08-24  8:37     ` Alexey Kardashevskiy
  0 siblings, 1 reply; 8+ messages in thread
From: Fabiano Rosas @ 2021-08-17 22:20 UTC (permalink / raw)
  To: Alexey Kardashevskiy, Paul Mackerras; +Cc: linux-kernel, kvm-ppc, linuxppc-dev

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> On 07/07/2021 14:13, Alexey Kardashevskiy wrote:

> alternatively move this debugfs stuff under the platform-independent
> directory, how about that?

That's a good idea. I only now realized we have two separate directories
for the same guest:

$ ls /sys/kernel/debug/kvm/ | grep $pid
19062-11
vm19062               

Looks like we would have to implement kvm_arch_create_vcpu_debugfs for
the vcpu information and add a similar hook for the vm.

>> ---
>>   arch/powerpc/kvm/book3s_hv.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>> index 1d1fcc290fca..0223ddc0eed0 100644
>> --- a/arch/powerpc/kvm/book3s_hv.c
>> +++ b/arch/powerpc/kvm/book3s_hv.c
>> @@ -5227,7 +5227,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
>>   	/*
>>   	 * Create a debugfs directory for the VM
>>   	 */
>> -	snprintf(buf, sizeof(buf), "vm%d", current->pid);
>> +	snprintf(buf, sizeof(buf), "vm%d-lp%ld", current->pid, lpid);
>>   	kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
>>   	kvmppc_mmu_debugfs_init(kvm);
>>   	if (radix_enabled())
>> 

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

* Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
  2021-08-17 22:20   ` Fabiano Rosas
@ 2021-08-24  8:37     ` Alexey Kardashevskiy
       [not found]       ` <2fe01488-5a9b-785e-7c05-1d527dead18d@ozlabs.ru>
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey Kardashevskiy @ 2021-08-24  8:37 UTC (permalink / raw)
  To: Fabiano Rosas; +Cc: linux-kernel, kvm-ppc, linuxppc-dev, Paul Mackerras



On 18/08/2021 08:20, Fabiano Rosas wrote:
> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> 
>> On 07/07/2021 14:13, Alexey Kardashevskiy wrote:
> 
>> alternatively move this debugfs stuff under the platform-independent
>> directory, how about that?
> 
> That's a good idea. I only now realized we have two separate directories
> for the same guest:
> 
> $ ls /sys/kernel/debug/kvm/ | grep $pid
> 19062-11
> vm19062
> 
> Looks like we would have to implement kvm_arch_create_vcpu_debugfs for
> the vcpu information and add a similar hook for the vm.

Something like that. From the git history, it looks like the ppc folder 
was added first and then the generic kvm folder was added but apparently 
they did not notice the ppc one due to natural reasons :)

If you are not too busy, can you please merge the ppc one into the 
generic one and post the patch, so we won't need to fix these 
duplication warnings again? Thanks,



>>> ---
>>>    arch/powerpc/kvm/book3s_hv.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>>> index 1d1fcc290fca..0223ddc0eed0 100644
>>> --- a/arch/powerpc/kvm/book3s_hv.c
>>> +++ b/arch/powerpc/kvm/book3s_hv.c
>>> @@ -5227,7 +5227,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
>>>    	/*
>>>    	 * Create a debugfs directory for the VM
>>>    	 */
>>> -	snprintf(buf, sizeof(buf), "vm%d", current->pid);
>>> +	snprintf(buf, sizeof(buf), "vm%d-lp%ld", current->pid, lpid);
>>>    	kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
>>>    	kvmppc_mmu_debugfs_init(kvm);
>>>    	if (radix_enabled())
>>>

-- 
Alexey

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

* Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
       [not found]       ` <2fe01488-5a9b-785e-7c05-1d527dead18d@ozlabs.ru>
@ 2021-09-01 14:23         ` Fabiano Rosas
  2021-09-01 15:26           ` Fabiano Rosas
  0 siblings, 1 reply; 8+ messages in thread
From: Fabiano Rosas @ 2021-09-01 14:23 UTC (permalink / raw)
  To: Alexey Kardashevskiy, Michael Ellerman
  Cc: linux-kernel, kvm-ppc, linuxppc-dev, Paul Mackerras

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> On 24/08/2021 18:37, Alexey Kardashevskiy wrote:
>> 
>> 
>> On 18/08/2021 08:20, Fabiano Rosas wrote:
>>> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
>>>
>>>> On 07/07/2021 14:13, Alexey Kardashevskiy wrote:
>>>
>>>> alternatively move this debugfs stuff under the platform-independent
>>>> directory, how about that?
>>>
>>> That's a good idea. I only now realized we have two separate directories
>>> for the same guest:
>>>
>>> $ ls /sys/kernel/debug/kvm/ | grep $pid
>>> 19062-11
>>> vm19062
>>>
>>> Looks like we would have to implement kvm_arch_create_vcpu_debugfs for
>>> the vcpu information and add a similar hook for the vm.
>> 
>> Something like that. From the git history, it looks like the ppc folder 
>> was added first and then the generic kvm folder was added but apparently 
>> they did not notice the ppc one due to natural reasons :)
>> 
>> If you are not too busy, can you please merge the ppc one into the 
>> generic one and post the patch, so we won't need to fix these 
>> duplication warnings again? Thanks,
>
>
>
> Turns out it is not that straight forward as I thought as the common KVM 
> debugfs entry is created after PPC HV KVM created its own and there is 
> no obvious way to change the order (no "post init" hook in
> kvmppc_ops).

That is why I mentioned creating a hook similar to
kvm_create_vcpu_debugfs in the common KVM code. kvm_create_vm_debugfs or
something.

Alternatively, maybe kvm_create_vm_debugfs could be moved earlier into
kvm_create_vm, before kvm_arch_post_init_vm and we could move our code
into kvm_arch_post_init_vm.

>
> Also, unlike the common KVM debugfs setup, we do not allocate structures 
> to support debugfs nodes so we do not leak anything to bother with a 
> mutex like 85cd39af14f4 did.
>
> So I'd stick to the original patch to reduce the noise in the dmesg, and 
> it also exposes lpid which I find rather useful for finding the right 
> partition scope tree in partition_tb.
>
> Michael?
>
>
>> 
>> 
>> 
>>>>> ---
>>>>>    arch/powerpc/kvm/book3s_hv.c | 2 +-
>>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/arch/powerpc/kvm/book3s_hv.c 
>>>>> b/arch/powerpc/kvm/book3s_hv.c
>>>>> index 1d1fcc290fca..0223ddc0eed0 100644
>>>>> --- a/arch/powerpc/kvm/book3s_hv.c
>>>>> +++ b/arch/powerpc/kvm/book3s_hv.c
>>>>> @@ -5227,7 +5227,7 @@ static int kvmppc_core_init_vm_hv(struct kvm 
>>>>> *kvm)
>>>>>        /*
>>>>>         * Create a debugfs directory for the VM
>>>>>         */
>>>>> -    snprintf(buf, sizeof(buf), "vm%d", current->pid);
>>>>> +    snprintf(buf, sizeof(buf), "vm%d-lp%ld", current->pid, lpid);
>>>>>        kvm->arch.debugfs_dir = debugfs_create_dir(buf, 
>>>>> kvm_debugfs_dir);
>>>>>        kvmppc_mmu_debugfs_init(kvm);
>>>>>        if (radix_enabled())
>>>>>
>> 

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

* Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename
  2021-09-01 14:23         ` Fabiano Rosas
@ 2021-09-01 15:26           ` Fabiano Rosas
  0 siblings, 0 replies; 8+ messages in thread
From: Fabiano Rosas @ 2021-09-01 15:26 UTC (permalink / raw)
  To: Alexey Kardashevskiy, Michael Ellerman
  Cc: linux-kernel, kvm-ppc, linuxppc-dev, Paul Mackerras

Fabiano Rosas <farosas@linux.ibm.com> writes:

> That is why I mentioned creating a hook similar to
> kvm_create_vcpu_debugfs in the common KVM code. kvm_create_vm_debugfs or
> something.

s/kvm/kvm_arch/


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

end of thread, other threads:[~2021-09-01 15:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07  4:13 [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename Alexey Kardashevskiy
2021-07-07 17:48 ` Fabiano Rosas
2021-07-08  2:22   ` Alexey Kardashevskiy
2021-08-13  9:50 ` Alexey Kardashevskiy
2021-08-17 22:20   ` Fabiano Rosas
2021-08-24  8:37     ` Alexey Kardashevskiy
     [not found]       ` <2fe01488-5a9b-785e-7c05-1d527dead18d@ozlabs.ru>
2021-09-01 14:23         ` Fabiano Rosas
2021-09-01 15:26           ` Fabiano Rosas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).