linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Fan <fanc.fnst@cn.fujitsu.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: <linux-kernel@vger.kernel.org>, <x86@kernel.org>, <hpa@zytor.com>,
	<mingo@redhat.com>, <bhe@redhat.com>, <keescook@chromium.org>,
	<yasu.isimatu@gmail.com>, <indou.takao@jp.fujitsu.com>,
	<lcapitulino@redhat.com>, <caoj.fnst@cn.fujitsu.com>,
	<douly.fnst@cn.fujitsu.com>
Subject: Re: [PATCH v3 1/4] x86/boot: Add acpitb.h to help parse acpi tables
Date: Fri, 20 Jul 2018 17:35:24 +0800	[thread overview]
Message-ID: <20180720093524.GB6739@localhost.localdomain> (raw)
In-Reply-To: <alpine.DEB.2.21.1807191717330.1693@nanos.tec.linutronix.de>

On Thu, Jul 19, 2018 at 05:19:43PM +0200, Thomas Gleixner wrote:
>On Tue, 17 Jul 2018, Chao Fan wrote:
>
>> In order to parse ACPI tables, reuse the head file linux/acpi.h,
>> so that the files in 'compressed' directory can read ACPI table
>> by including this head file.
>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>>  arch/x86/boot/compressed/acpitb.h | 50 +++++++++++++++++++++++++++++++
>>  1 file changed, 50 insertions(+)
>>  create mode 100644 arch/x86/boot/compressed/acpitb.h
>> 
>> diff --git a/arch/x86/boot/compressed/acpitb.h b/arch/x86/boot/compressed/acpitb.h
>> new file mode 100644
>> index 000000000000..fd2bba23f447
>> --- /dev/null
>> +++ b/arch/x86/boot/compressed/acpitb.h
>> @@ -0,0 +1,50 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#include <linux/acpi.h>
>> +
>> +#define ACPI_MAX_TABLES                128
>> +
>> +/* Function to get ACPI SRAT table pointer. */
>> +struct acpi_table_header *get_acpi_srat_table(void);
>> +
>> +#ifdef ACPI_BIG_ENDIAN
>> +
>> +#define ACPI_MOVE_64_TO_64(d, s) \
>> +{((u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7]; \
>> +((u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6]; \
>> +((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[5]; \
>> +((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[4]; \
>> +((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3]; \
>> +((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2]; \
>> +((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1]; \
>> +((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0]; }
>
>Whats wrong with be64_to_cpu() ?

Hi tglx,

Thanks for your review.
ACPI_MOVE_64_TO_64 and ACPI_MOVE_16_TO_32 are copied from arch/x86/boot/compressed/acpitb.h
cause I though copying the old code is reliable.
I will delete these two definitions and only using le64_to_cpu and
le16_to_cpu may be enough(since ACPI table is in little endian).
And also add more comments in next version.

Thanks,
Chao Fan

>
>> +
>> +#define ACPI_MOVE_16_TO_32(d, s) \
>> +{(*(u32 *)(void *)(d)) = 0; \
>> +((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1]; \
>> +((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0]; }
>
>Huch? 
>
>> +
>> +#else
>> +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
>> +
>> +#define ACPI_MOVE_64_TO_64(d, s) \
>> +{*(u64 *)(void *)(d) = *(u64 *)(void *)(s); }
>> +
>> +#define ACPI_MOVE_16_TO_32(d, s) \
>> +{*(u32 *)(void *)(d) = *(u16 *)(void *)(s); }
>> +
>> +#else
>> +#define ACPI_MOVE_64_TO_64(d, s) \
>> +{((u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0]; \
>> +((u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1]; \
>> +((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2]; \
>> +((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3]; \
>> +((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[4]; \
>> +((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[5]; \
>> +((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[6]; \
>> +((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[7]; }
>
>And why doees this have to be done bytewise? Some comments would be
>helpful.
>
>Thanks,
>
>	tglx
>
>



  reply	other threads:[~2018-07-20  9:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 10:04 [PATCH v3 0/4] x86/boot/KASLR: Parse ACPI table and limit kaslr in immovable memory Chao Fan
2018-07-17 10:04 ` [PATCH v3 1/4] x86/boot: Add acpitb.h to help parse acpi tables Chao Fan
2018-07-19 15:19   ` Thomas Gleixner
2018-07-20  9:35     ` Chao Fan [this message]
2018-07-17 10:04 ` [PATCH v3 2/4] x86/boot: Add acpitb.c to " Chao Fan
2018-07-19 15:22   ` Thomas Gleixner
2018-07-20  0:57     ` Chao Fan
2018-07-17 10:04 ` [PATCH v3 3/4] x86/boot/KASLR: Walk srat tables to filter immovable memory Chao Fan
2018-07-17 10:04 ` [PATCH v3 4/4] x86/boot/KASLR: Limit kaslr to choosing the " Chao Fan

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=20180720093524.GB6739@localhost.localdomain \
    --to=fanc.fnst@cn.fujitsu.com \
    --cc=bhe@redhat.com \
    --cc=caoj.fnst@cn.fujitsu.com \
    --cc=douly.fnst@cn.fujitsu.com \
    --cc=hpa@zytor.com \
    --cc=indou.takao@jp.fujitsu.com \
    --cc=keescook@chromium.org \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yasu.isimatu@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).