All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Deng, Emily" <Emily.Deng@amd.com>
To: "Chen, JingWen" <JingWen.Chen2@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Chen, JingWen" <JingWen.Chen2@amd.com>,
	"Zhao, Victor" <Victor.Zhao@amd.com>,
	"Liu, Monk" <Monk.Liu@amd.com>
Subject: RE: [PATCH] drm/amd/amdgpu:save psp ring wptr in SRIOV to avoid attack
Date: Wed, 26 May 2021 07:14:26 +0000	[thread overview]
Message-ID: <PH0PR12MB54176F7CDBAD4134AA57889C8F249@PH0PR12MB5417.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20210526065459.26368-1-Jingwen.Chen2@amd.com>

[AMD Official Use Only]

Reviewed-by: Emily Deng <Emily.Deng@amd.com>

>-----Original Message-----
>From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Jingwen
>Chen
>Sent: Wednesday, May 26, 2021 2:55 PM
>To: amd-gfx@lists.freedesktop.org
>Cc: Chen, JingWen <JingWen.Chen2@amd.com>; Zhao, Victor
><Victor.Zhao@amd.com>; Liu, Monk <Monk.Liu@amd.com>
>Subject: [PATCH] drm/amd/amdgpu:save psp ring wptr in SRIOV to avoid attack
>
>From: Victor Zhao <Victor.Zhao@amd.com>
>
>save psp ring wptr in SRIOV to avoid attack to avoid extra changes to
>MP0_SMN_C2PMSG_102 reg
>
>Change-Id: Idee78e8c1c781463048f2f6311fdc70488ef05b2
>Signed-off-by: Victor Zhao <Victor.Zhao@amd.com>
>Signed-off-by: Jingwen Chen <Jingwen.Chen2@amd.com>
>---
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 1 +
>drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 1 +
>drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 3 ++-
> drivers/gpu/drm/amd/amdgpu/psp_v3_1.c   | 3 ++-
> 4 files changed, 6 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>index 55378c6b9722..20e06b3ec686 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
>@@ -2701,6 +2701,7 @@ int psp_ring_cmd_submit(struct psp_context *psp,
>       /* Update the write Pointer in DWORDs */
>       psp_write_ptr_reg = (psp_write_ptr_reg + rb_frame_size_dw) %
>ring_size_dw;
>       psp_ring_set_wptr(psp, psp_write_ptr_reg);
>+      ring->ring_wptr = psp_write_ptr_reg;
>       return 0;
> }
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
>index 46a5328e00e0..60aa99a39a74 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
>@@ -76,6 +76,7 @@ struct psp_ring
>       uint64_t                        ring_mem_mc_addr;
>       void                            *ring_mem_handle;
>       uint32_t                        ring_size;
>+      uint32_t                        ring_wptr;
> };
>
> /* More registers may will be supported */ diff --git
>a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
>b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
>index 1f2e7e35c91e..4a32b0c84ef4 100644
>--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
>+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
>@@ -474,6 +474,7 @@ static int psp_v11_0_ring_create(struct psp_context
>*psp,
>                       return ret;
>               }
>
>+              ring->ring_wptr = 0;
>               /* Write low address of the ring to C2PMSG_102 */
>               psp_ring_reg = lower_32_bits(ring->ring_mem_mc_addr);
>               WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102,
>psp_ring_reg); @@ -733,7 +734,7 @@ static uint32_t
>psp_v11_0_ring_get_wptr(struct psp_context *psp)
>       struct amdgpu_device *adev = psp->adev;
>
>       if (amdgpu_sriov_vf(adev))
>-              data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102);
>+              data = psp->km_ring.ring_wptr;
>       else
>               data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67);
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
>b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
>index f2e725f72d2f..160f78eb6403 100644
>--- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
>+++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
>@@ -237,6 +237,7 @@ static int psp_v3_1_ring_create(struct psp_context *psp,
>                       return ret;
>               }
>
>+              ring->ring_wptr = 0;
>               /* Write low address of the ring to C2PMSG_102 */
>               psp_ring_reg = lower_32_bits(ring->ring_mem_mc_addr);
>               WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102,
>psp_ring_reg); @@ -379,7 +380,7 @@ static uint32_t
>psp_v3_1_ring_get_wptr(struct psp_context *psp)
>       struct amdgpu_device *adev = psp->adev;
>
>       if (amdgpu_sriov_vf(adev))
>-              data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102);
>+              data = psp->km_ring.ring_wptr;
>       else
>               data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67);
>       return data;
>--
>2.25.1
>
>_______________________________________________
>amd-gfx mailing list
>amd-gfx@lists.freedesktop.org
>https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free
>desktop.org%2Fmailman%2Flistinfo%2Famd-
>gfx&amp;data=04%7C01%7CEmily.Deng%40amd.com%7C36c0aa6490f94ad29ac
>608d920133b77%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6375
>76089720049840%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJ
>QIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=PV29Nx
>wj0ASCRlw%2BHWal6Ghk%2FkLe6Qhxd2yCwA%2BiI9Q%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2021-05-26  7:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26  6:55 [PATCH] drm/amd/amdgpu:save psp ring wptr in SRIOV to avoid attack Jingwen Chen
2021-05-26  7:14 ` Deng, Emily [this message]
2021-05-26  7:24 ` Liu, Monk
2021-05-26  7:43   ` Chen, JingWen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH0PR12MB54176F7CDBAD4134AA57889C8F249@PH0PR12MB5417.namprd12.prod.outlook.com \
    --to=emily.deng@amd.com \
    --cc=JingWen.Chen2@amd.com \
    --cc=Monk.Liu@amd.com \
    --cc=Victor.Zhao@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.