From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::243; helo=mail-it0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x243.google.com (mail-it0-x243.google.com [IPv6:2607:f8b0:4001:c0b::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7921F220D4BE9 for ; Thu, 16 Nov 2017 01:27:43 -0800 (PST) Received: by mail-it0-x243.google.com with SMTP id f187so5182947itb.1 for ; Thu, 16 Nov 2017 01:31:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hRTzUb/zj9/ooh/SWs//aaWWgR9x2e5j+7nHmkOfw6w=; b=DroAxHWVdcgrrqbhWE9sYvJ0en8MOAjms0jvK6c9ZlhORgLOlRWLC+zqjlXcGYR7PU YUvQx8JO0VQTeNs5fjcw4vdxdA1bKLeQdYrUWNaKp5l5JH9XldipcFaE/0BUBy0tUoAf i5/U1IE1AyO9iFvj+ktaY2p/THJHRiUYv4i6M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hRTzUb/zj9/ooh/SWs//aaWWgR9x2e5j+7nHmkOfw6w=; b=SoxDWa4b6S/QolkcgZIOrGyI7Du5FlKBYuvvZQ7tPF+I8ryA6aZ2JmRY7wY/BTfzj2 ESfQmnbYiS9SUsUOrBXI39moQbw63X1t1+wTL4CMVLUIZJuzqalmdKRgvLe9BGFGdvJW G2eBKuvLKFTQ9Q2LxMMurSyUm9woDCnh44W+szwVm5YpBh8UDnI6TIuij4pzvT2bVuWd hIv9NnQJ1drJqSk7qPGMMCOTGQ7z9yxjJtn02Pq8sg2M08Kh9LaqfKRi+pZha5KMkQfX ZHjSOA8GkQKEtUNjfSXjs3KcxyJsFLdC5N+U3Y29j1BG1rtHQxmap01hNG/OvkVs3RUN c+/w== X-Gm-Message-State: AJaThX4uyJHL+lAzJnoG7jE/hG57GFw+dNVjemHDceN//KZRvPstlWNk bHHlRsbnVskCZmXRVRUIDvyHROMFLiTq/0hgLlXzXw== X-Google-Smtp-Source: AGs4zMaeQZKn65JKv2pDTlWWe6ITLbG8muJ5h/vTbJ8rOHS324Pk/0l0TZ65oP0ngPkSj44mmg0TG3DCtR/KiT5W6Wo= X-Received: by 10.36.145.203 with SMTP id i194mr1526534ite.73.1510824712155; Thu, 16 Nov 2017 01:31:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.104.3 with HTTP; Thu, 16 Nov 2017 01:31:51 -0800 (PST) In-Reply-To: <20171115215703.16491-2-lersek@redhat.com> References: <20171115215703.16491-1-lersek@redhat.com> <20171115215703.16491-2-lersek@redhat.com> From: Ard Biesheuvel Date: Thu, 16 Nov 2017 09:31:51 +0000 Message-ID: To: Laszlo Ersek Cc: edk2-devel-01 , Eric Dong , Jordan Justen Subject: Re: [PATCH v2 1/4] UefiCpuPkg/ResetVector/Vtf0: document segment register setup X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2017 09:27:43 -0000 Content-Type: text/plain; charset="UTF-8" On 15 November 2017 at 21:57, Laszlo Ersek wrote: > "Main.asm" calls TransitionFromReal16To32BitFlat (and does some other > things) before it jumps to the platform's SEC entry point. > > TransitionFromReal16To32BitFlat enters big real mode, and sets the DS, ES, > FS, GS, and SS registers to offset ("selector") LINEAR_SEL in the GDT > (defined in "UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm"). The > GDT entry ("segment descriptor") at LINEAR_SEL defines a segment covering > the full 32-bit address space, meant for "read/write data". > > Document this fact for all the affected segment registers, as output > parameters for TransitionFromReal16To32BitFlat, saying "Selector allowing > flat access to all addresses". > > For 64-bit SEC, "Main.asm" calls Transition32FlatTo64Flat in addition, > between calling TransitionFromReal16To32BitFlat and jumping to the SEC > entry point. Transition32FlatTo64Flat enters long mode. In long mode, > segmentation is largely ignored: > > - all segments are considered flat (covering the whole 64-bit address > space), > > - with the (possible) exception of FS and GS, whose bases can still be > changed, albeit with new methods, not through the GDT. (Through the > IA32_FS_BASE and IA32_GS_BASE Model Specific Registers, and/or the > WRFSBASE, WRGSBASE and SWAPGS instructions.) > > Thus, document the segment registers with the same "Selector allowing flat > access to all addresses" language on the "Main.asm" level too, since that > is valid for both 32-bit and 64-bit modes. > > (Technically, "Main.asm" does not return, but RBP/EBP, passed similarly to > the SEC entry point, is already documented as an output parameter.) > > Cc: Ard Biesheuvel > Cc: Eric Dong > Cc: Jordan Justen > Suggested-by: Jordan Justen > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel > --- > > Notes: > v2: > - new patch [Jordan] > > UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm | 6 ++++++ > UefiCpuPkg/ResetVector/Vtf0/Main.asm | 5 +++++ > 2 files changed, 11 insertions(+) > > diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm > index 146df600a63b..bc68c8dd749a 100644 > --- a/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm > +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia16/Real16ToFlat32.asm > @@ -21,6 +21,12 @@ BITS 16 > ; > ; Modified: EAX, EBX > ; > +; @param[out] DS Selector allowing flat access to all addresses > +; @param[out] ES Selector allowing flat access to all addresses > +; @param[out] FS Selector allowing flat access to all addresses > +; @param[out] GS Selector allowing flat access to all addresses > +; @param[out] SS Selector allowing flat access to all addresses > +; > TransitionFromReal16To32BitFlat: > > debugShowPostCode POSTCODE_16BIT_MODE > diff --git a/UefiCpuPkg/ResetVector/Vtf0/Main.asm b/UefiCpuPkg/ResetVector/Vtf0/Main.asm > index ebfb9015d49c..57f080688b6f 100644 > --- a/UefiCpuPkg/ResetVector/Vtf0/Main.asm > +++ b/UefiCpuPkg/ResetVector/Vtf0/Main.asm > @@ -24,6 +24,11 @@ BITS 16 > ; @param[in,out] DI 'BP': boot-strap processor, or > ; 'AP': application processor > ; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV) > +; @param[out] DS Selector allowing flat access to all addresses > +; @param[out] ES Selector allowing flat access to all addresses > +; @param[out] FS Selector allowing flat access to all addresses > +; @param[out] GS Selector allowing flat access to all addresses > +; @param[out] SS Selector allowing flat access to all addresses > ; > ; @return None This routine jumps to SEC and does not return > ; > -- > 2.14.1.3.gb7cf6e02401b > >