public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Qiaowei Ren <qiaowei.ren@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Gang Wei <gang.wei@intel.com>
Subject: Re: [PATCH v5] x86, tboot: iomem fixes
Date: Tue, 06 Aug 2013 15:27:17 -0700	[thread overview]
Message-ID: <52017845.5000205@zytor.com> (raw)
In-Reply-To: <1374337612-6899-1-git-send-email-qiaowei.ren@intel.com>

On 07/20/2013 09:26 AM, Qiaowei Ren wrote:
>  
>  	/* now map TXT heap */
> -	heap_base = ioremap(*(u64 *)(config + TXTCR_HEAP_BASE),
> -			    *(u64 *)(config + TXTCR_HEAP_SIZE));
> +	heap_base = ioremap(readl(config + TXTCR_HEAP_BASE),
> +			    readl(config + TXTCR_HEAP_SIZE));

You are changing u64 references to readl()... this means you are doing
only 32-bit reads.

>  	iounmap(config);
>  	if (!heap_base)
>  		return NULL;
>  
>  	/* walk heap to SinitMleData */
>  	/* skip BiosData */
> -	heap_ptr = heap_base + *(u64 *)heap_base;
> +	heap_ptr = heap_base + readq(heap_base);
>  	/* skip OsMleData */
> -	heap_ptr += *(u64 *)heap_ptr;
> +	heap_ptr += readq(heap_ptr);
>  	/* skip OsSinitData */
> -	heap_ptr += *(u64 *)heap_ptr;
> +	heap_ptr += readq(heap_ptr);

As I believe Ingo already commented on, readq() only exists on 64 bits.

You can #include <asm-generic/io-64-nonatomic-lo-hi.h> to remedy that.

>  	/* now points to SinitMleDataSize; set to SinitMleData */
>  	heap_ptr += sizeof(u64);
>  	/* get addr of DMAR table */
> +	dmar_tbl_off = readl(heap_ptr +
> +			offsetof(struct sinit_mle_data, vtd_dmars_off));
>  	dmar_tbl = (struct acpi_table_header *)(heap_ptr +
> -		   ((struct sinit_mle_data *)heap_ptr)->vtd_dmars_off -
> -		   sizeof(u64));
> +			dmar_tbl_off - sizeof(u64));
>  
>  	/* don't unmap heap because dmar.c needs access to this */
>  

If you are using accessors here, what about dmar_tbl itself?

	-hpa




      parent reply	other threads:[~2013-08-06 22:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-20 16:26 [PATCH v5] x86, tboot: iomem fixes Qiaowei Ren
2013-07-22  8:50 ` Ingo Molnar
2013-08-06 22:27 ` H. Peter Anvin [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=52017845.5000205@zytor.com \
    --to=hpa@zytor.com \
    --cc=gang.wei@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=qiaowei.ren@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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