diff mbox series

drm/i915/gem: Return SIGBUS for wrong mapping parameters

Message ID 20240617124115.260250-1-andi.shyti@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/gem: Return SIGBUS for wrong mapping parameters | expand

Commit Message

Andi Shyti June 17, 2024, 12:41 p.m. UTC
We normally issue a warning when incorrect memory parameters are
provided. Typically, providing erroneous addresses to mmap,
results in a segmentation fault, and the default behavior
is to return VM_FAULT_SIGBUS.

This can happen for example when remap_io_mapping() or
remap_io_sg() return -EINVAL.

Because VM_FAULT_SIGBUS is already returned when memory
boundaries are improperly handled and numerous warnings are
already generated, avoid redundant logging to prevent
overprinting by translating -EINVAL to VM_FAULT_SIGBUS in the
i915_error_to_vmf_fault() helper.

Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andi Shyti June 20, 2024, 3:14 p.m. UTC | #1
Hi,

> index a2195e28b625..698ff42b004a 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -223,6 +223,7 @@ static vm_fault_t i915_error_to_vmf_fault(int err)
>  	default:
>  		WARN_ONCE(err, "unhandled error in %s: %i\n", __func__, err);
>  		fallthrough;
> +	case -EINVAL: /* the memory parameters provided are wrong */

no point for this... it was offline nacked :-)

Thanks,
Andi

>  	case -EIO: /* shmemfs failure from swap device */
>  	case -EFAULT: /* purged object */
>  	case -ENODEV: /* bad object, how did you get here! */
> -- 
> 2.45.1
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index a2195e28b625..698ff42b004a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -223,6 +223,7 @@  static vm_fault_t i915_error_to_vmf_fault(int err)
 	default:
 		WARN_ONCE(err, "unhandled error in %s: %i\n", __func__, err);
 		fallthrough;
+	case -EINVAL: /* the memory parameters provided are wrong */
 	case -EIO: /* shmemfs failure from swap device */
 	case -EFAULT: /* purged object */
 	case -ENODEV: /* bad object, how did you get here! */