[1/2] x86/mm/iommu/sva: Fix error code for LAM enabling failure due to SVA

Message ID 20230403111020.3136-2-kirill.shutemov@linux.intel.com
State New
Headers
Series Couple of trivial fixes for LAM vs. SVA interaction |

Commit Message

Kirill A. Shutemov April 3, 2023, 11:10 a.m. UTC
  Normally, LAM and SVA are mutually exclusive. LAM enabling will fail if
SVA is already in use.

Correct error code for the failure. EINTR is nonsensical there.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Fixes: 23e5d9ec2bab ("x86/mm/iommu/sva: Make LAM and SVA mutually exclusive")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
 arch/x86/kernel/process_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Dmitry Vyukov April 3, 2023, 1:55 p.m. UTC | #1
On Mon, 3 Apr 2023 at 13:10, Kirill A. Shutemov
<kirill.shutemov@linux.intel.com> wrote:
>
> Normally, LAM and SVA are mutually exclusive. LAM enabling will fail if
> SVA is already in use.
>
> Correct error code for the failure. EINTR is nonsensical there.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Fixes: 23e5d9ec2bab ("x86/mm/iommu/sva: Make LAM and SVA mutually exclusive")
> Reported-by: Dmitry Vyukov <dvyukov@google.com>

Reviewed-by: Dmitry Vyukov <dvyukov@google.com>

> ---
>  arch/x86/kernel/process_64.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> index 74c7e84a94d8..c7dfd727c9ec 100644
> --- a/arch/x86/kernel/process_64.c
> +++ b/arch/x86/kernel/process_64.c
> @@ -760,7 +760,7 @@ static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)
>
>         if (mm_valid_pasid(mm) &&
>             !test_bit(MM_CONTEXT_FORCE_TAGGED_SVA, &mm->context.flags))
> -               return -EINTR;
> +               return -EINVAL;
>
>         if (mmap_write_lock_killable(mm))
>                 return -EINTR;
> --
> 2.39.2
>
  
Dave Hansen April 6, 2023, 3:31 p.m. UTC | #2
On 4/3/23 04:10, Kirill A. Shutemov wrote:
> Normally, LAM and SVA are mutually exclusive. LAM enabling will fail if
> SVA is already in use.
> 
> Correct error code for the failure. EINTR is nonsensical there.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Fixes: 23e5d9ec2bab ("x86/mm/iommu/sva: Make LAM and SVA mutually exclusive")
> Reported-by: Dmitry Vyukov <dvyukov@google.com>

Hi Kirill,

These look fine. But in the future, Link:'s for Reported-by's would be
very appreciated if the discussion happened in public.
  
Kirill A. Shutemov April 6, 2023, 3:59 p.m. UTC | #3
On Thu, Apr 06, 2023 at 08:31:40AM -0700, Dave Hansen wrote:
> On 4/3/23 04:10, Kirill A. Shutemov wrote:
> > Normally, LAM and SVA are mutually exclusive. LAM enabling will fail if
> > SVA is already in use.
> > 
> > Correct error code for the failure. EINTR is nonsensical there.
> > 
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Fixes: 23e5d9ec2bab ("x86/mm/iommu/sva: Make LAM and SVA mutually exclusive")
> > Reported-by: Dmitry Vyukov <dvyukov@google.com>
> 
> Hi Kirill,
> 
> These look fine. But in the future, Link:'s for Reported-by's would be
> very appreciated if the discussion happened in public.

Got it.

For this one it is:

Link: https://lore.kernel.org/all/CACT4Y+YfqSMsZArhh25TESmG-U4jO5Hjphz87wKSnTiaw2Wrfw@mail.gmail.com
  

Patch

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 74c7e84a94d8..c7dfd727c9ec 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -760,7 +760,7 @@  static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)
 
 	if (mm_valid_pasid(mm) &&
 	    !test_bit(MM_CONTEXT_FORCE_TAGGED_SVA, &mm->context.flags))
-		return -EINTR;
+		return -EINVAL;
 
 	if (mmap_write_lock_killable(mm))
 		return -EINTR;