mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Denys Vlasenko <dvlasenk@redhat.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: brgerst@gmail.com, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, luto@amacapital.net,
	linux-kernel@vger.kernel.org, jpoimboe@redhat.com,
	luto@kernel.org, peterz@infradead.org, bp@alien8.de,
	hpa@zytor.com, dave.hansen@intel.com, tglx@linutronix.de,
	mingo@kernel.org, linux-tip-commits@vger.kernel.org
Subject: Re: [tip:x86/mm] x86/asm: Remove __VIRTUAL_MASK_SHIFT==47 assert
Date: Wed, 5 Apr 2017 13:50:27 +0200	[thread overview]
Message-ID: <ccde7771-0bfc-579f-5682-ea7bb130205a@redhat.com> (raw)
In-Reply-To: <20170405111258.5ro7momzscweinuf@black.fi.intel.com>



On 04/05/2017 01:12 PM, Kirill A. Shutemov wrote:
> On Tue, Apr 04, 2017 at 05:36:33PM +0200, Denys Vlasenko wrote:
>>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
>>> index 044d18e..f07b4ef 100644
>>> --- a/arch/x86/entry/entry_64.S
>>> +++ b/arch/x86/entry/entry_64.S
>>> @@ -265,12 +265,9 @@ return_from_SYSCALL_64:
>>>  	 *
>>>  	 * If width of "canonical tail" ever becomes variable, this will need
>>>  	 * to be updated to remain correct on both old and new CPUs.
>>> +	 *
>>> +	 * Change top 16 bits to be the sign-extension of 47th bit
>>
>> The comment above stops being correct: it's not necessary 16 top bits
>> we sign-extend now. With larger __VIRTUAL_MASK_SHIFT for 5-level translation,
>> it will become 7 bits (if I do the math right).
>
> Does the patch below look okay to you?
>
>>>  	 */
>>> -	.ifne __VIRTUAL_MASK_SHIFT - 47
>>> -	.error "virtual address width changed -- SYSRET checks need update"
>>> -	.endif
>>> -
>>> -	/* Change top 16 bits to be the sign-extension of 47th bit */
>>>  	shl	$(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
>>>  	sar	$(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
>>
>> The bigger problem here would be the future boot-time choice of 4/5-level
>> page tables: __VIRTUAL_MASK_SHIFT will need to depend on that choice,
>> but in this location it is preferable to not use any variables
>> (memory references).
>
> Yeah. Will see what I will be able to come up with. Not sure yet.
>
> -------------------8<----------------------
>
> From 2433cf4f8847bbc41cc2b02d6af4f191b3b5a0c5 Mon Sep 17 00:00:00 2001
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Date: Wed, 5 Apr 2017 14:06:15 +0300
> Subject: [PATCH] x86/asm: Fix comment in return_from_SYSCALL_64
>
> On x86-64 __VIRTUAL_MASK_SHIFT depends on paging mode now.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
>  arch/x86/entry/entry_64.S | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 607d72c4a485..c70e064d9592 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -266,7 +266,8 @@ return_from_SYSCALL_64:
>  	 * If width of "canonical tail" ever becomes variable, this will need
>  	 * to be updated to remain correct on both old and new CPUs.
>  	 *
> -	 * Change top 16 bits to be the sign-extension of 47th bit
> +	 * Change top bits to match most significant valuable bit (47 or 56
> +	 * depending on paging mode) in the address.

Er.... "Change top bits ... ((47 or 56 [bits] depending on paging mode)"?
I know that's wrong and that's not what you meant to say,
but it can be read this way too. "47th" instead of "47"
would eliminate this reading, but you removed "th".

Spell it out to eliminate any chance of confusion:

	Change top bits to match most significant bit (47th or 56th bit
	depending on paging mode) in the address.


>  	 */
>  	shl	$(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
>  	sar	$(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
>

  reply	other threads:[~2017-04-05 11:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  8:07 [PATCHv3 0/7] x86: 5-level paging enabling for v4.12, Part 3 Kirill A. Shutemov
2017-03-30  8:07 ` [PATCHv3 1/7] x86/boot: Detect 5-level paging support Kirill A. Shutemov
2017-04-04  8:28   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2017-03-30  8:07 ` [PATCHv3 2/7] x86/asm: Remove __VIRTUAL_MASK_SHIFT==47 assert Kirill A. Shutemov
2017-04-04  8:29   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2017-04-04 15:36     ` Denys Vlasenko
2017-04-05 11:12       ` Kirill A. Shutemov
2017-04-05 11:50         ` Denys Vlasenko [this message]
2017-04-05 12:00           ` Kirill A. Shutemov
2017-04-11  7:12             ` Ingo Molnar
2017-03-30  8:07 ` [PATCHv3 3/7] x86/mm: Define virtual memory map for 5-level paging Kirill A. Shutemov
2017-04-04  8:29   ` [tip:x86/mm] " tip-bot for Kirill A. Shutemov
2017-03-30  8:07 ` [PATCHv3 4/7] x86/paravirt: Make paravirt code support " Kirill A. Shutemov
2017-04-04  8:30   ` [tip:x86/mm] x86/paravirt: Add 5-level support to the paravirt code tip-bot for Kirill A. Shutemov
2017-03-30  8:07 ` [PATCHv3 5/7] x86/mm: Add basic defines/helpers for CONFIG_X86_5LEVEL Kirill A. Shutemov
2017-04-04  8:30   ` [tip:x86/mm] x86/mm: Add basic defines/helpers for CONFIG_X86_5LEVEL=y tip-bot for Kirill A. Shutemov
2017-03-30  8:07 ` [PATCHv3 6/7] x86/kasan: Extend to support 5-level paging Kirill A. Shutemov
2017-04-04  8:31   ` [tip:x86/mm] x86/kasan: Extend KASAN " tip-bot for Kirill A. Shutemov
2017-03-30  8:07 ` [PATCHv3 7/7] x86/espfix: Add " Kirill A. Shutemov
2017-04-04  8:31   ` [tip:x86/mm] x86/espfix: Add support for " tip-bot for Kirill A. Shutemov

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=ccde7771-0bfc-579f-5682-ea7bb130205a@redhat.com \
    --to=dvlasenk@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@intel.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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®