AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ken Xue <kxue-5C7GfCeVMHo@public.gmane.org>
To: "Nils Wallménius"
	<nils.wallmenius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	dl.SRDC_SW_GPUVirtualization-5C7GfCeVMHo@public.gmane.org,
	Ken.Xue-5C7GfCeVMHo@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH V2] amdgpu/drm: Refine the way to check
Date: Wed, 21 Dec 2016 02:08:03 +0800	[thread overview]
Message-ID: <20161220180802.GA29575@amd.com> (raw)
In-Reply-To: <CA+nq7DtXaf3eQ+80fSjgw4tQWqV62CgG082AECycCoj0M9j-qA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

The 12/21/2016 10:44, Nils Wallménius wrote:
> Hi Ken, a comment below
> 
> 
> Den 21 dec. 2016 08:19 skrev "Xue, Ken" <Ken.Xue@amd.com>:
> 
> There are several ways to check out a ATOMBIOS. In previous codes, try
> a new way to fetch out vbios/rom, until current vbios/rom is started with
> 0x55AA, then check if this vbios is ATOMBIOS. Now, try a new way to fetch
> out vbios until all flags of ATOMBIOS are verified.
> 
> Signed-off-by: Ken Xue <Ken.Xue@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c   | 174
> ++++++++++++++++-------------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   8 +-
>  2 files changed, 102 insertions(+), 80 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> index 4f973a9..a6fa91f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
> @@ -42,6 +42,44 @@
>  #define AMD_IS_VALID_VBIOS(p) ((p)[0] == 0x55 && (p)[1] == 0xAA)
>  #define AMD_VBIOS_LENGTH(p) ((p)[2] << 9)
> 
> +/* Check if current bios is an ATOM BIOS.
> + * Return true if it is ATOM BIOS. Otherwise, return false.
> + */
> +static bool check_atom_bios(uint8_t *bios, size_t size)
> +{
> +       uint16_t tmp, bios_header_start;
> +
> +       if (!bios || size < 0x49) {
> +               DRM_INFO("vbios mem is null or mem size is wrong\n");
> +               return false;
> +       }
> +
> +       if (!AMD_IS_VALID_VBIOS(bios)) {
> +               DRM_INFO("BIOS signature incorrect %x %x\n", bios[0],
> bios[1]);
> +               return false;
> +       }
> +
> +       tmp = bios[0x18] | (bios[0x19] << 8);
> +       if (bios[tmp + 0x14] != 0x0) {
> +               DRM_INFO("Not an x86 BIOS ROM\n");
> +               return false;
> +       }
> +
> +       bios_header_start = bios[0x48] | (bios[0x49] << 8);
> +       if (!bios_header_start) {
> +               DRM_INFO("Can't locate bios header\n");
> +               return false;
> +       }
> +       tmp = bios_header_start + 4;
> +       if (!memcmp(bios + tmp, "ATOM", 4) ||
> +           !memcmp(bios + tmp, "MOTA", 4) ||
> +           (size < tmp))
> 
> 
> Is the last condition here correct? Can you have valid atombios without the
> signature? Maybe add a comment if that's true. Also the extra parents
> aren't necessary.
> 
> Best regards
> Nils
> 
Thanks for your comments. It should be a mistake.

if (size < tmp) {
	DRM_INFO("BIOS header is broken\n");
	return false;
}


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

      parent reply	other threads:[~2016-12-20 18:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21  7:03 [PATCH V2] amdgpu/drm: Refine the way to check Xue, Ken
     [not found] ` <CY4PR12MB134963093979F255981DF512FB930-rpdhrqHFk04TyeVEJk5hrgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-12-21  9:44   ` Nils Wallménius
     [not found]     ` <CA+nq7DtXaf3eQ+80fSjgw4tQWqV62CgG082AECycCoj0M9j-qA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-20 18:08       ` Ken Xue [this message]

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=20161220180802.GA29575@amd.com \
    --to=kxue-5c7gfcevmho@public.gmane.org \
    --cc=Ken.Xue-5C7GfCeVMHo@public.gmane.org \
    --cc=alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=dl.SRDC_SW_GPUVirtualization-5C7GfCeVMHo@public.gmane.org \
    --cc=nils.wallmenius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox