linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: Change flag passed to GUP fast in sev_pin_memory()
@ 2020-04-23 15:24 Janakarajan Natarajan
  2020-04-23 20:34 ` Ira Weiny
  0 siblings, 1 reply; 2+ messages in thread
From: Janakarajan Natarajan @ 2020-04-23 15:24 UTC (permalink / raw)
  To: linux-kernel, x86, kvm
  Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, Ira Weiny, Mike Marshall,
	Andrew Morton, Brijesh Singh, Janakarajan Natarajan

When trying to lock read-only pages, sev_pin_memory() fails because FOLL_WRITE
is used as the flag for get_user_pages_fast().

Commit 73b0140bf0fe ("mm/gup: change GUP fast to use flags rather than a write
'bool'") updated the get_user_pages_fast() call sites to use flags, but
incorrectly updated the call in sev_pin_memory(). As the original coding of this
call was correct, revert the change made by that commit.

Fixes: 73b0140bf0fe ("mm/gup: change GUP fast to use flags rather than a write 'bool'")
Signed-off-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
---
 arch/x86/kvm/svm/sev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index cf912b4aaba8..89f7f3aebd31 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -345,7 +345,7 @@ static struct page **sev_pin_memory(struct kvm *kvm, unsigned long uaddr,
 		return NULL;
 
 	/* Pin the user virtual address. */
-	npinned = get_user_pages_fast(uaddr, npages, FOLL_WRITE, pages);
+	npinned = get_user_pages_fast(uaddr, npages, write ? FOLL_WRITE : 0, pages);
 	if (npinned != npages) {
 		pr_err("SEV: Failure locking %lu pages.\n", npages);
 		goto err;
-- 
2.17.1


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

* Re: [PATCH] KVM: SVM: Change flag passed to GUP fast in sev_pin_memory()
  2020-04-23 15:24 [PATCH] KVM: SVM: Change flag passed to GUP fast in sev_pin_memory() Janakarajan Natarajan
@ 2020-04-23 20:34 ` Ira Weiny
  0 siblings, 0 replies; 2+ messages in thread
From: Ira Weiny @ 2020-04-23 20:34 UTC (permalink / raw)
  To: Janakarajan Natarajan
  Cc: linux-kernel, x86, kvm, Paolo Bonzini, Sean Christopherson,
	Vitaly Kuznetsov, Wanpeng Li, Jim Mattson, Joerg Roedel,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	Mike Marshall, Andrew Morton, Brijesh Singh

On Thu, Apr 23, 2020 at 10:24:19AM -0500, Janakarajan Natarajan wrote:
> When trying to lock read-only pages, sev_pin_memory() fails because FOLL_WRITE
> is used as the flag for get_user_pages_fast().
> 
> Commit 73b0140bf0fe ("mm/gup: change GUP fast to use flags rather than a write
> 'bool'") updated the get_user_pages_fast() call sites to use flags, but
> incorrectly updated the call in sev_pin_memory(). As the original coding of this
> call was correct, revert the change made by that commit.
> 
> Fixes: 73b0140bf0fe ("mm/gup: change GUP fast to use flags rather than a write 'bool'")
> Signed-off-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> ---
>  arch/x86/kvm/svm/sev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index cf912b4aaba8..89f7f3aebd31 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -345,7 +345,7 @@ static struct page **sev_pin_memory(struct kvm *kvm, unsigned long uaddr,
>  		return NULL;
>  
>  	/* Pin the user virtual address. */
> -	npinned = get_user_pages_fast(uaddr, npages, FOLL_WRITE, pages);
> +	npinned = get_user_pages_fast(uaddr, npages, write ? FOLL_WRITE : 0, pages);
>  	if (npinned != npages) {
>  		pr_err("SEV: Failure locking %lu pages.\n", npages);
>  		goto err;
> -- 
> 2.17.1
> 

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

end of thread, other threads:[~2020-04-23 20:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 15:24 [PATCH] KVM: SVM: Change flag passed to GUP fast in sev_pin_memory() Janakarajan Natarajan
2020-04-23 20:34 ` Ira Weiny

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).