Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-19 Thread 'Joerg Roedel'
On Wed, May 12, 2021 at 11:32:35AM +0200, Joerg Roedel wrote: > On Wed, May 12, 2021 at 10:58:20AM +0200, Juergen Gross wrote: > > No, those were used before, but commit 9da3f2b7405440 broke Xen's use > > case. That is why I did commit 1457d8cf7664f. > > [...] > > Having the distinction between

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread Joerg Roedel
On Wed, May 12, 2021 at 08:57:53AM -0700, Dave Hansen wrote: > The changelog _helps_, but using a "user" function to handle kernel MMIO > for its error handling properties seems like it's begging for a comment. > > __put_user() also seems to have fun stuff like __chk_user_ptr(). It all > seems

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread Dave Hansen
On 5/12/21 1:37 AM, 'Joerg Roedel' wrote: > I also thought about adding page_fault_disable()/page_fault_enable() > calls, but being in atomic context is enough according to the > faulthandler_disabled() implementation. That would be nice to add to a comment:

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread Dave Hansen
On 5/12/21 12:54 AM, Joerg Roedel wrote: > The put_user() and get_user() functions do checks on the address which is > passed to them. They check whether the address is actually a user-space > address and whether its fine to access it. They also call might_fault() > to indicate that they could

RE: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread David Laight
From: Juergen Gross > Sent: 12 May 2021 09:58 > > On 12.05.21 10:50, 'Joerg Roedel' wrote: > > On Wed, May 12, 2021 at 10:16:12AM +0200, Juergen Gross wrote: > >> You want something like xen_safe_[read|write]_ulong(). > > > > From a first glance I can't see it, what is the difference between the

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread Joerg Roedel
On Wed, May 12, 2021 at 10:58:20AM +0200, Juergen Gross wrote: > No, those were used before, but commit 9da3f2b7405440 broke Xen's use > case. That is why I did commit 1457d8cf7664f. I see, thanks for the heads-up. So here this is not a big issue, because when an access to kernel space faults

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread Juergen Gross via Virtualization
On 12.05.21 10:50, 'Joerg Roedel' wrote: On Wed, May 12, 2021 at 10:16:12AM +0200, Juergen Gross wrote: You want something like xen_safe_[read|write]_ulong(). From a first glance I can't see it, what is the difference between the xen_safe_*_ulong() functions and __get_user()/__put_user()?

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread 'Joerg Roedel'
On Wed, May 12, 2021 at 10:16:12AM +0200, Juergen Gross wrote: > You want something like xen_safe_[read|write]_ulong(). >From a first glance I can't see it, what is the difference between the xen_safe_*_ulong() functions and __get_user()/__put_user()? The only difference I can see is that

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread 'Joerg Roedel'
On Wed, May 12, 2021 at 08:04:33AM +, David Laight wrote: > That can't be right at all. > __put/get_user() are only valid on user addresses and will try to > fault in a missing page - so can sleep. Yes, in general these functions can sleep, but not in this context. They are called in atomic

Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread Juergen Gross via Virtualization
On 12.05.21 10:04, David Laight wrote: From: Joerg Sent: 12 May 2021 08:55 From: Joerg Roedel The put_user() and get_user() functions do checks on the address which is passed to them. They check whether the address is actually a user-space address and whether its fine to access it. They also

RE: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread David Laight
From: Joerg > Sent: 12 May 2021 08:55 > > From: Joerg Roedel > > The put_user() and get_user() functions do checks on the address which is > passed to them. They check whether the address is actually a user-space > address and whether its fine to access it. They also call might_fault() > to

[PATCH 3/6] x86/sev-es: Use __put_user()/__get_user

2021-05-12 Thread Joerg Roedel
From: Joerg Roedel The put_user() and get_user() functions do checks on the address which is passed to them. They check whether the address is actually a user-space address and whether its fine to access it. They also call might_fault() to indicate that they could fault and possibly sleep. All