* [PATCH RFC] drm/amdgpu: Block userspace mapping of IO
@ 2025-04-16 7:28 Ujwal Kundur
2025-04-16 7:51 ` Christian König
0 siblings, 1 reply; 4+ messages in thread
From: Ujwal Kundur @ 2025-04-16 7:28 UTC (permalink / raw)
To: alexander.deucher, christian.koenig
Cc: airlied, simona, lijo.lazar, sunil.khatri, Hawking.Zhang, Jun.Ma2,
Yunxiang.Li, amd-gfx, dri-devel, linux-kernel, Ujwal Kundur
This is a RFC patch for blocking userspace mapping of IO register(s)
before ioremap() calls are made. Out of the available IRQ sources, CRTC
seemed the most appropriate for this task, however I'm not quite sure
about that as well as the type, which I've set to 0.
If I understand correctly, we actually want to block certain ioctls from
userspace that can interfere with ioremap but I don't see a dedicated
source for that.
Signed-off-by: Ujwal Kundur <ujwal.kundur@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index a30111d2c3ea..365af52af6e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -47,6 +47,7 @@
#include <linux/vga_switcheroo.h>
#include <linux/efi.h>
#include "amdgpu.h"
+#include "amdgpu_irq.h"
#include "amdgpu_trace.h"
#include "amdgpu_i2c.h"
#include "atom.h"
@@ -4367,7 +4368,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
ratelimit_set_flags(&adev->throttling_logging_rs, RATELIMIT_MSG_ON_RELEASE);
/* Registers mapping */
- /* TODO: block userspace mapping of io register */
+ /* Block userspace mapping of io register */
+ amdgpu_irq_put(adev, &adev->crtc_irq, 0);
+
if (adev->asic_type >= CHIP_BONAIRE) {
adev->rmmio_base = pci_resource_start(adev->pdev, 5);
adev->rmmio_size = pci_resource_len(adev->pdev, 5);
@@ -4380,6 +4383,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
atomic_set(&adev->pm.pwr_state[i], POWER_STATE_UNKNOWN);
adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size);
+
+ amdgpu_irq_get(adev, &adev->crtc_irq, 0);
+
if (!adev->rmmio)
return -ENOMEM;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH RFC] drm/amdgpu: Block userspace mapping of IO
2025-04-16 7:28 [PATCH RFC] drm/amdgpu: Block userspace mapping of IO Ujwal Kundur
@ 2025-04-16 7:51 ` Christian König
2025-04-16 11:43 ` Ujwal Kundur
0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2025-04-16 7:51 UTC (permalink / raw)
To: Ujwal Kundur, alexander.deucher
Cc: airlied, simona, lijo.lazar, sunil.khatri, Hawking.Zhang, Jun.Ma2,
Yunxiang.Li, amd-gfx, dri-devel, linux-kernel
Am 16.04.25 um 09:28 schrieb Ujwal Kundur:
> This is a RFC patch for blocking userspace mapping of IO register(s)
> before ioremap() calls are made. Out of the available IRQ sources, CRTC
> seemed the most appropriate for this task, however I'm not quite sure
> about that as well as the type, which I've set to 0.
Hui what? Why do you think that grabbing a reference to an interrupt would block userspace mapping of IO registers?
Christian.
>
> If I understand correctly, we actually want to block certain ioctls from
> userspace that can interfere with ioremap but I don't see a dedicated
> source for that.
>
> Signed-off-by: Ujwal Kundur <ujwal.kundur@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index a30111d2c3ea..365af52af6e5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -47,6 +47,7 @@
> #include <linux/vga_switcheroo.h>
> #include <linux/efi.h>
> #include "amdgpu.h"
> +#include "amdgpu_irq.h"
> #include "amdgpu_trace.h"
> #include "amdgpu_i2c.h"
> #include "atom.h"
> @@ -4367,7 +4368,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
> ratelimit_set_flags(&adev->throttling_logging_rs, RATELIMIT_MSG_ON_RELEASE);
>
> /* Registers mapping */
> - /* TODO: block userspace mapping of io register */
> + /* Block userspace mapping of io register */
> + amdgpu_irq_put(adev, &adev->crtc_irq, 0);
> +
> if (adev->asic_type >= CHIP_BONAIRE) {
> adev->rmmio_base = pci_resource_start(adev->pdev, 5);
> adev->rmmio_size = pci_resource_len(adev->pdev, 5);
> @@ -4380,6 +4383,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
> atomic_set(&adev->pm.pwr_state[i], POWER_STATE_UNKNOWN);
>
> adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size);
> +
> + amdgpu_irq_get(adev, &adev->crtc_irq, 0);
> +
> if (!adev->rmmio)
> return -ENOMEM;
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH RFC] drm/amdgpu: Block userspace mapping of IO
2025-04-16 7:51 ` Christian König
@ 2025-04-16 11:43 ` Ujwal Kundur
2025-04-16 12:29 ` Christian König
0 siblings, 1 reply; 4+ messages in thread
From: Ujwal Kundur @ 2025-04-16 11:43 UTC (permalink / raw)
To: Christian König
Cc: alexander.deucher, airlied, simona, lijo.lazar, sunil.khatri,
Hawking.Zhang, Jun.Ma2, Yunxiang.Li, amd-gfx, dri-devel,
linux-kernel
Thanks for your response.
> Hui what? Why do you think that grabbing a reference to an interrupt would block userspace mapping of IO registers?
It looks like I am missing a lot of pieces to do this, I'll try again
once I have a better understanding.
Sorry about that and thanks again for your time.
--- Ujwal.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] drm/amdgpu: Block userspace mapping of IO
2025-04-16 11:43 ` Ujwal Kundur
@ 2025-04-16 12:29 ` Christian König
0 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2025-04-16 12:29 UTC (permalink / raw)
To: Ujwal Kundur
Cc: alexander.deucher, airlied, simona, lijo.lazar, sunil.khatri,
Hawking.Zhang, Jun.Ma2, Yunxiang.Li, amd-gfx, dri-devel,
linux-kernel
Am 16.04.25 um 13:43 schrieb Ujwal Kundur:
> Thanks for your response.
>
>> Hui what? Why do you think that grabbing a reference to an interrupt would block userspace mapping of IO registers?
> It looks like I am missing a lot of pieces to do this, I'll try again
> once I have a better understanding.
>
> Sorry about that and thanks again for your time.
No problem. If you have questions about the driver stack then just ask.
Regards,
Christian.
>
> --- Ujwal.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-16 13:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 7:28 [PATCH RFC] drm/amdgpu: Block userspace mapping of IO Ujwal Kundur
2025-04-16 7:51 ` Christian König
2025-04-16 11:43 ` Ujwal Kundur
2025-04-16 12:29 ` Christian König
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.