mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] x86/boot: replace __PHYSICAL_START with LOAD_PHYSICAL_ADDR
Date: Thu, 14 Mar 2024 03:23:20 +0000	[thread overview]
Message-ID: <20240314032320.iug2hvzyblychanu@master> (raw)
In-Reply-To: <ZfF/ekjP9R91dw2j@gmail.com>

On Wed, Mar 13, 2024 at 11:29:33AM +0100, Ingo Molnar wrote:
>
>* Wei Yang <richard.weiyang@gmail.com> wrote:
>
>> Both __PHYSICAL_START and LOAD_PHYSICAL_ADDR are defined to get aligned
>> CONFIG_PHYSICAL_START, so we can replace __PHYSICAL_START with
>> LOAD_PHYSICAL_ADDR. And then remove the definition of __PHYSICAL_START,
>> which is only used to define __START_KERNEL.
>> 
>> Since <asm/boot.h> includes <asm/pgtable_types.h>, which includes
>> <asm/page_types.h>, it is fine to move definition from <asm/boot.h> to
>> <asm/page_types.h>.
>> 
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> ---
>>  arch/x86/include/asm/boot.h       | 5 -----
>>  arch/x86/include/asm/page_types.h | 8 +++++---
>>  2 files changed, 5 insertions(+), 8 deletions(-)
>> 
>> diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
>> index a38cc0afc90a..12cbc57d0128 100644
>> --- a/arch/x86/include/asm/boot.h
>> +++ b/arch/x86/include/asm/boot.h
>> @@ -6,11 +6,6 @@
>>  #include <asm/pgtable_types.h>
>>  #include <uapi/asm/boot.h>
>>  
>> -/* Physical address where kernel should be loaded. */
>> -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
>> -				+ (CONFIG_PHYSICAL_ALIGN - 1)) \
>> -				& ~(CONFIG_PHYSICAL_ALIGN - 1))
>> -
>>  /* Minimum kernel alignment, as a power of two */
>>  #ifdef CONFIG_X86_64
>>  # define MIN_KERNEL_ALIGN_LG2	PMD_SHIFT
>> diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
>> index 86bd4311daf8..acc1620fd121 100644
>> --- a/arch/x86/include/asm/page_types.h
>> +++ b/arch/x86/include/asm/page_types.h
>> @@ -31,10 +31,12 @@
>>  
>>  #define VM_DATA_DEFAULT_FLAGS	VM_DATA_FLAGS_TSK_EXEC
>>  
>> -#define __PHYSICAL_START	ALIGN(CONFIG_PHYSICAL_START, \
>> -				      CONFIG_PHYSICAL_ALIGN)
>> +/* Physical address where kernel should be loaded. */
>> +#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
>> +				+ (CONFIG_PHYSICAL_ALIGN - 1)) \
>> +				& ~(CONFIG_PHYSICAL_ALIGN - 1))
>
>I agree with this simplification, but the ALIGN() expression is far easier 
>to read, so please keep that one instead of the open-coded version.
>

I just tried to define LOAD_PHYSICAL_ADDR by ALIGN, but face a compile error
on compressed/head_[32|64].o.

$ make arch/x86/boot/compressed/head_64.o
  CALL    scripts/checksyscalls.sh
  DESCEND objtool
  INSTALL libsubcmd_headers
  AS      arch/x86/boot/compressed/head_64.o
arch/x86/boot/compressed/head_64.S: Assembler messages:
arch/x86/boot/compressed/head_64.S:154: Error: junk (0x1000000,0x200000)' after expression
arch/x86/boot/compressed/head_64.S:154: Error: number of operands mismatch for 16' after expression
arch/x86/boot/compressed/head_64.S:157: Error: junk mov'
arch/x86/boot/compressed/head_64.S:330: Error: junk (0x1000000,0x200000)' after expression
arch/x86/boot/compressed/head_64.S:330: Error: number of operands mismatch for 16' after expression
arch/x86/boot/compressed/head_64.S:333: Error: junk movq'

If my understanding is correct, the reason is linkage.h defines ALIGN, which
is ".balign xxx". Maybe this is why original LOAD_PHYSICAL_ADDR doesn't use
ALIGN.

So is this ok to keep the open-coded definition?

>Thanks,
>
>	Ingo

-- 
Wei Yang
Help you, Help me

  parent reply	other threads:[~2024-03-14  3:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  7:58 [PATCH 0/4] Cleanup vmlinux.lds.S Wei Yang
2024-03-13  7:58 ` [PATCH 1/4] vmlinux.lds.h: fix a typo in comment Wei Yang
2024-03-13 10:39   ` [tip: x86/build] vmlinux.lds.h: Fix " tip-bot2 for Wei Yang
2024-03-13  7:58 ` [PATCH 2/4] x86/boot: replace __PHYSICAL_START with LOAD_PHYSICAL_ADDR Wei Yang
2024-03-13 10:29   ` Ingo Molnar
2024-03-14  0:54     ` Wei Yang
2024-03-14  3:23     ` Wei Yang [this message]
2024-03-14  9:25       ` Ingo Molnar
2024-03-15  0:57         ` Wei Yang
2024-03-16 17:44           ` Wei Yang
2024-03-13 10:29   ` Nikolay Borisov
2024-03-14  0:54     ` Wei Yang
2024-03-22 10:59   ` [tip: x86/build] x86/boot: Replace " tip-bot2 for Wei Yang
2024-03-13  7:58 ` [PATCH 3/4] x86/vmlinux.lds.S: remove conditional definition of LOAD_OFFSET Wei Yang
2024-03-13 10:39   ` [tip: x86/build] x86/vmlinux.lds.S: Remove " tip-bot2 for Wei Yang
2024-03-13 13:18     ` Borislav Petkov
2024-03-14  0:59       ` Wei Yang
2024-03-13  7:58 ` [PATCH 4/4] x86/vmlinux.lds.S: take __START_KERNEL out conditional definition Wei Yang
2024-03-13 10:39   ` [tip: x86/build] x86/vmlinux.lds.S: Take " tip-bot2 for Wei Yang

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=20240314032320.iug2hvzyblychanu@master \
    --to=richard.weiyang@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.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

all inboxes | Powered by JetHome®