Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1390430imu; Wed, 16 Jan 2019 18:50:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN7+Z5VE+07oab4BBMN35QDxquTX+m9sTcLld/XeGyp5ssSnAalo5ocJaqzTzBQWSOlxnJy3 X-Received: by 2002:a17:902:680f:: with SMTP id h15mr13041296plk.40.1547693444039; Wed, 16 Jan 2019 18:50:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547693444; cv=none; d=google.com; s=arc-20160816; b=bWUNlkAdWL0foJlA4Y3oOlRZ70taEFODmUqmfTuJra/HUx58TKNsCDNzkm+N718TJ8 NHm8SAh4Ql+DM7J1yMSaq2f5paWepyhKLPaBZKhFI10yPpS9ddDuzKJTqE0Tz9BxeofG 1SfFGtROoUVJWaSdvZJeMHIpxQPbCff86R/dbKFrYoLpfNlCag+QTob0RjBzCvAjtyvK nx8ChXSQD90fFBnLEKDuJCSxbe4MAD/n91IHeUcBucBTTK0QvGtF/SjV5q+V/LLYRq/r 8asDTmZ77pXG2XRmve37NCiGOSiIB4/vmLnquLozhP7X4Qw8CT6rUkI4orcnOCpOKBP/ VumA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Y/j13scaejr/SeZWO60KJTofTLBVmcXb8HeNXaOY6uk=; b=QIUfxUWgpuNZ0dz0ibVGyaa2MfHlZ+iwcJ3IwPD7CCiIU/OJinVPJ8+hGd/4/AaqzC djPccx9B/P/bj61KsnpFYCRHjdmWCJhN0T9QGZjUmzhFsPfGnDa129RX3ZEir3DlARYW WI/boQBkFj5ikhSfKOiYQpgx2MCrbvpLROYmstseqzNWqB5PZuyY4hW1NhgbdsVxFShm khqrcUP6awfQIVN8sm8H8IXeqmz9NwZHhCcqO0i0CHg3cbOjWfH9A/yChXHwY+wu8kPB 6WSenohRmQHVubPYLQcW4k7wmh/7CZNTZ2vHO8nonbslD5dKb/rgphJ/9AvfABcBlo64 P5dQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si320302pla.173.2019.01.16.18.50.25; Wed, 16 Jan 2019 18:50:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391820AbfAPJoB (ORCPT + 99 others); Wed, 16 Jan 2019 04:44:01 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:6891 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731932AbfAPJoA (ORCPT ); Wed, 16 Jan 2019 04:44:00 -0500 X-IronPort-AV: E=Sophos;i="5.56,485,1539619200"; d="scan'208";a="52134393" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Jan 2019 17:43:58 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id E8E734BAD9BE; Wed, 16 Jan 2019 17:43:55 +0800 (CST) Received: from [10.167.226.60] (10.167.226.60) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 16 Jan 2019 17:43:55 +0800 Subject: Re: question about head_64.S To: Thomas Gleixner CC: Ingo Molnar , , "H. Peter Anvin" , , LKML References: <6aebbf86-2ba1-c517-dc47-054279daec49@cn.fujitsu.com> From: Cao jin Message-ID: <642e4121-229f-7627-7f1d-737eb8ed4e5f@cn.fujitsu.com> Date: Wed, 16 Jan 2019 17:44:26 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.60] X-yoursite-MailScanner-ID: E8E734BAD9BE.AAEEE X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/15/19 11:55 PM, Thomas Gleixner wrote: > On Tue, 15 Jan 2019, Cao jin wrote: > >> Hi, >> I have been digging into this file for a while, and I still have 2 >> questions unclear, hope to get your help. >> >> 1. >> At the entry of startup_64, we set all the data segment registers to 0, >> according to commit 08da5a2ca("x86_64: Early segment setup for VT"), it >> is said to accelerate the decompression under VT. I don't know Intel VT, >> but I did test under physical machine and virtual machine(with KVM, and >> intel VT enabled in BIOS) with following patch: >> >> diff --git a/arch/x86/boot/compressed/head_64.S >> b/arch/x86/boot/compressed/head_64.S >> index 58f6a467f1fa..595f3c300173 100644 >> --- a/arch/x86/boot/compressed/head_64.S >> +++ b/arch/x86/boot/compressed/head_64.S >> @@ -260,12 +260,12 @@ ENTRY(startup_64) >> */ >> >> /* Setup data segments. */ >> - xorl %eax, %eax >> - movl %eax, %ds >> - movl %eax, %es >> - movl %eax, %ss >> - movl %eax, %fs >> - movl %eax, %gs >> +// xorl %eax, %eax >> +// movl %eax, %ds >> +// movl %eax, %es >> +// movl %eax, %ss >> +// movl %eax, %fs >> +// movl %eax, %gs >> >> I don't see any obvious booting time difference, is there anything I missed? >> Also, I don't find explicit document saying we should zero these >> registers under VT. > > The decompressor is position independent code, so all segments have to be > set to 0. > Thank you Thomas! But I've never heard that PIC is correlated with segment register value, could you elaborate a little bit? Because as I know, startup_64 is in long mode, and CPU will treat all segment(except fs, gs) base as 0, no matter whatever in them. And until now, I only see fs is touched when parsing command line, not see any explicit gs usage. On the other hand, I test the patch above, it can boot up, so seems segment register value here is not necessary to be 0? > The patch you mentioned was just adding fs/gs to the list of segments > which are cleared and the commit message is not very clear. Though if you > dig further down then you find the original version of that patch: > > commit ffb6017563aa("[PATCH] x86-64: x86_64 - Fix FS/GS registers for VT execution") > > That one has a proper explantaion. > Oh, I still not reach to the real kernel itself yet. At first glance, "but it is important to reload them in protected mode" make sense to me. But more confusion rise up: under 64-bit boot protocol, we can have more than one entry? startup_64 in both: arch/x86/kernel/head_64.S and arch/x86/boot/compressed/head_64.S can be jumped to via bootloader? Seems Documentation/x86/boot.txt doesn't say that. -- Sincerely, Cao jin