From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH 4/4] x86/boot: Size the boot/directmap mappings dynamically
Date: Wed, 15 Jan 2020 10:40:15 +0100 [thread overview]
Message-ID: <1cdae18b-7c16-6dc1-9e36-50a1bed9d17a@suse.com> (raw)
In-Reply-To: <6e708726-9769-f8a0-340d-5c2a739ae4ca@citrix.com>
On 14.01.2020 18:27, Andrew Cooper wrote:
> On 14/01/2020 17:02, Jan Beulich wrote:
>> On 13.01.2020 18:50, Andrew Cooper wrote:
>>> --- a/xen/arch/x86/boot/head.S
>>> +++ b/xen/arch/x86/boot/head.S
>>> @@ -687,14 +687,19 @@ trampoline_setup:
>>> * handling/walking), and identity map Xen into bootmap (needed for
>>> * the transition into long mode), using 2M superpages.
>>> */
>>> - lea sym_esi(start),%ebx
>>> - lea (1<<L2_PAGETABLE_SHIFT)*7+(PAGE_HYPERVISOR_RWX|_PAGE_PSE)(%ebx),%eax
>>> - shr $(L2_PAGETABLE_SHIFT-3),%ebx
>>> - mov $8,%ecx
>>> -1: mov %eax,sym_fs(l2_bootmap)-8(%ebx,%ecx,8)
>>> - mov %eax,sym_fs(l2_directmap)-8(%ebx,%ecx,8)
>>> - sub $(1<<L2_PAGETABLE_SHIFT),%eax
>>> - loop 1b
>>> + lea sym_esi(_start), %ecx
>>> + lea -1 + sym_esi(_end), %edx
>> This looks pretty odd - does
>>
>> lea sym_esi(_end) - 1, %edx
>>
>> not work?
>
> No:
>
> head.S: Assembler messages:
> head.S:521: Error: junk `(%esi)-1' after expression
>
> but it is not at all surprising when you expand the macro:
>
> lea (_end - start)(%esi) - 1, %edx
>
> The expression for the displacement ends up split across both sides of
> the SIB.
Hmm, seems I've mis-remembered that stuff ahead of ( and after
) gets concatenated.
>>> + lea _PAGE_PSE + PAGE_HYPERVISOR_RWX(%ecx), %eax /* PTE to write. */
>>> + shr $L2_PAGETABLE_SHIFT, %ecx /* First slot to write. */
>>> + shr $L2_PAGETABLE_SHIFT, %edx /* Final slot to write. */
>>> +
>>> +1: mov %eax, sym_offs(l2_bootmap) (%esi, %ecx, 8)
>>> + mov %eax, sym_offs(l2_directmap)(%esi, %ecx, 8)
>> I guess I could have noticed this on the previous patch already:
>> This would look better as
>>
>> 1: mov %eax, sym_esi(l2_bootmap, %ecx, 8)
>> mov %eax, sym_esi(l2_directmap, %ecx, 8)
>>
>> Can sym_esi() perhaps be made
>>
>> #define sym_esi(sym, extra...) sym_offs(sym)(%esi, ## extra)
>>
>> ?
>
> I considered and dismissed this approach. Yes, the code is slightly
> shorter, but at the expense of readability.
>
> The advantage of the longhand version is that it is obvious which half
> is the displacement expression, and which half is the SIB.
>
> The reduced version leaves a distinct possibility of %ecx being mistaken
> as the base register, rather than the index.
With it being sym_esi() that gets used, I don't see any such risk.
But anyway, if you're convinced of the longer form being better,
so be it then.
>>> --- a/xen/arch/x86/xen.lds.S
>>> +++ b/xen/arch/x86/xen.lds.S
>>> @@ -384,6 +384,3 @@ ASSERT((trampoline_end - trampoline_start) < TRAMPOLINE_SPACE - MBI_SPACE_MIN,
>>> "not enough room for trampoline and mbi data")
>>> ASSERT((wakeup_stack - wakeup_stack_start) >= WAKEUP_STACK_MIN,
>>> "wakeup stack too small")
>>> -
>>> -/* Plenty of boot code assumes that Xen isn't larger than 16M. */
>>> -ASSERT(_end - _start <= MB(16), "Xen too large for early-boot assumptions")
>> Following your reply to the cover letter, this can't be dropped just yet.
>
> Correct.
>
>> Even when that remaining issue got addressed, I think it would be better
>> to keep it, altering the bound to GB(1).
>
> A 1G check wouldn't be correct.
>
> We've already got a more suitable one, which is the check that Xen
> doesn't encroach into the stubs range.
Oh, right. If only that check was correct. I guess it ought to be
using &, not |, and perhaps also __image_base__ == XEN_VIRT_START.
I'll give this a try and send a patch unless in the course of
doing so I realize there's a reason for it being the way it is.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-01-15 9:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 17:50 [Xen-devel] [PATCH 0/4] x86: Remove 16M total-size restriction Andrew Cooper
2020-01-13 17:50 ` [Xen-devel] [PATCH 1/4] x86/boot: Rename l?_identmap to l?_directmap Andrew Cooper
2020-01-14 16:16 ` Jan Beulich
2020-01-13 17:50 ` [Xen-devel] [PATCH 2/4] x86/page: Remove bifrucated PAGE_HYPERVISOR constant Andrew Cooper
2020-01-13 17:50 ` [Xen-devel] [PATCH 2/4] x86/page: Remove bifurcated " Andrew Cooper
2020-01-14 16:25 ` Jan Beulich
2020-01-15 12:53 ` Andrew Cooper
2020-01-15 13:07 ` Jan Beulich
2020-01-15 14:08 ` [Xen-devel] [PATCH v2 " Andrew Cooper
2020-01-16 9:46 ` Jan Beulich
2020-01-13 17:50 ` [Xen-devel] [PATCH 3/4] x86/boot: Create the l2_xenmap[] mappings dynamically Andrew Cooper
2020-01-14 16:45 ` Jan Beulich
2020-01-14 19:31 ` Andrew Cooper
2020-01-15 9:23 ` Jan Beulich
2020-01-16 19:41 ` Andrew Cooper
2020-01-13 17:50 ` [Xen-devel] [PATCH 4/4] x86/boot: Size the boot/directmap " Andrew Cooper
2020-01-14 17:02 ` Jan Beulich
2020-01-14 17:27 ` Andrew Cooper
2020-01-15 9:40 ` Jan Beulich [this message]
2020-01-15 10:21 ` Jan Beulich
2020-01-14 13:03 ` [Xen-devel] [PATCH 0/4] x86: Remove 16M total-size restriction Andrew Cooper
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=1cdae18b-7c16-6dc1-9e36-50a1bed9d17a@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).