Received: by 10.192.165.148 with SMTP id m20csp4861296imm; Tue, 1 May 2018 05:18:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo5ynJhb4z4KQrwPGIFo6r7fjoaTSlbAN+hp8hunRkkdCLRom5Sm3ivXGVX9GGElQBM6kkO X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr16169924pla.125.1525177089508; Tue, 01 May 2018 05:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525177089; cv=none; d=google.com; s=arc-20160816; b=dAaHh6ui9quvSqgoDZr9oomVq7E2Uua0CWdlshXJKI7IeH4dDWUc5yRQxicAly51Ol zriLKlY4t6I3RLVSHI9qaulRR5i1Z7ySyVdHo76LeIKaRQZojaBZLiFyrhR7uIMsf+BY o0fNL/r50U/ezhkDu6Q76p/D84trP9irBaf1i7ykxlhmwieZ71fZWjgpJva4zOCnV+rj +D7/8V2xP0P4sZ8HlU6NKKyEOshN9Lpmy9q5AlUrpukindDIMiwPicDF1OnUpTrfxCam HGpkmuKe5G8aDJf2GFFrWIU9uPQk5f3/QrpbockJx8Fn1uTNyGVmhBAiYAeXFdyQ6uBV svog== 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:dkim-signature :arc-authentication-results; bh=oPNAwli6aFH2FAQvu3zhNrp1ULVbmLCLKtSWnihq8DE=; b=VdxsRNBROtYwc1QP31YcLT/HpC8ukpZCut7dhMgG8YHtUQenQBxVs1NJijFfIBRlUT tZrenTUmvxlume0fw/zUTXNYTmpnfct+n9Mf3vx0vjNxveOiSA/Ew371U0bL8ixHZSyN 9qr7YmApZKb7sykCMFCrs9f2qvkkE81Emlj09sQNqPrxm3jF9FCcXGyfOQI44ZVGpmCy HTNiLoelbpajtgWzcu9Iizij3ffGghaS0GBeSx84qabf8jaXQI7oM36AxlZQ+1T6h7PL q7AFzll5Bc317fpzSXbTB963XzwGAQ8FRLH++i9sYwfRpmlWFizEEFsOXTyWY2qw2Z4H uxSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Wvd0rcsV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14-v6si7737921pgf.93.2018.05.01.05.17.55; Tue, 01 May 2018 05:18:09 -0700 (PDT) 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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Wvd0rcsV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755667AbeEAMQ0 (ORCPT + 99 others); Tue, 1 May 2018 08:16:26 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45122 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755223AbeEAMQV (ORCPT ); Tue, 1 May 2018 08:16:21 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w41CG2Wc076715; Tue, 1 May 2018 12:16:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=oPNAwli6aFH2FAQvu3zhNrp1ULVbmLCLKtSWnihq8DE=; b=Wvd0rcsV2tn3o1+ty9RcQQKrh7c5ihDiSVpdPSBQYbRtd0v9CXehOkhkMXjpYSUlLqq6 hKlbQ0Qz4sac1YaC2AVyL+bQYe1JJNDWNS8inWD+6wsMZEAmWqh+vdUOpnMdNgUp6d3n b41H2hkf5McUwF+iOw1c3D1YQiNVkKsoqo4LmORl1seI0rW5sJmhbZzw72lBbhK8IcAy aFnszTioa3YKo2RKqEJpDLtW8HUT7jJxNksxme8EyM6qoSAplyhhAnR+Ij3qCpE2c/rt YrFFEo8KdwPzKazAzia2QkdkFdQY+IkstBAN3Ln/qt/ek69WR4tF/Qn6BANlJLB5SSfN /A== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2hmgdjfgv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 May 2018 12:16:14 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w41CGDJY013935 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 May 2018 12:16:14 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w41CGDX6008584; Tue, 1 May 2018 12:16:13 GMT Received: from [10.0.2.15] (/108.49.193.195) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 01 May 2018 05:16:13 -0700 Subject: Re: [Xen-devel] [PATCH 1/4] xen/PVH: Replace GDT_ENTRY with explicit constant To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, jgross@suse.com, stable@vger.kernel.org References: <20180430162339.17143-1-boris.ostrovsky@oracle.com> <20180430162339.17143-2-boris.ostrovsky@oracle.com> <20180430165704.bkce56nzx3giodbd@MacBook-Pro-de-Roger.local> <310676e9-d527-421b-a367-a6a8ada5255d@oracle.com> <20180501075352.ffx5dqaedo657nub@MacBook-Pro-de-Roger.local> From: Boris Ostrovsky Message-ID: <776256de-1e9d-9e7a-2352-0f8ce0e7f5c8@oracle.com> Date: Tue, 1 May 2018 08:16:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180501075352.ffx5dqaedo657nub@MacBook-Pro-de-Roger.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8879 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805010124 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2018 03:53 AM, Roger Pau Monné wrote: > On Mon, Apr 30, 2018 at 02:07:43PM -0400, Boris Ostrovsky wrote: >> On 04/30/2018 12:57 PM, Roger Pau Monné wrote: >>> On Mon, Apr 30, 2018 at 12:23:36PM -0400, Boris Ostrovsky wrote: >>>> Latest binutils release (2.29.1) will no longer allow proper computation >>>> of GDT entries on 32-bits, with warning: >>>> >>>> arch/x86/xen/xen-pvh.S: Assembler messages: >>>> arch/x86/xen/xen-pvh.S:150: Warning: shift count out of range (32 is not between 0 and 31) >>>> arch/x86/xen/xen-pvh.S:150: Warning: shift count out of range (40 is not between 0 and 31) >>>> arch/x86/xen/xen-pvh.S:150: Warning: shift count out of range (32 is not between 0 and 31) >>>> arch/x86/xen/xen-pvh.S:152: Warning: shift count out of range (32 is not between 0 and 31) >>>> arch/x86/xen/xen-pvh.S:152: Warning: shift count out of range (40 is not between 0 and 31) >>>> arch/x86/xen/xen-pvh.S:152: Warning: shift count out of range (32 is not between 0 and 31) >>>> >>>> Use explicit value of the entry instead of using GDT_ENTRY() macro. >>>> >>>> Signed-off-by: Boris Ostrovsky >>>> Cc: stable@vger.kernel.org >>>> --- >>>> arch/x86/xen/xen-pvh.S | 6 +++--- >>>> 1 file changed, 3 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/arch/x86/xen/xen-pvh.S b/arch/x86/xen/xen-pvh.S >>>> index e1a5fbe..934f7d4 100644 >>>> --- a/arch/x86/xen/xen-pvh.S >>>> +++ b/arch/x86/xen/xen-pvh.S >>>> @@ -145,11 +145,11 @@ gdt_start: >>>> .quad 0x0000000000000000 /* NULL descriptor */ >>>> .quad 0x0000000000000000 /* reserved */ >>>> #ifdef CONFIG_X86_64 >>>> - .quad GDT_ENTRY(0xa09a, 0, 0xfffff) /* __KERNEL_CS */ >>>> + .quad 0x00af9a000000ffff /* __BOOT_CS */ >>>> #else >>>> - .quad GDT_ENTRY(0xc09a, 0, 0xfffff) /* __KERNEL_CS */ >>>> + .quad 0x00cf9a000000ffff /* __BOOT_CS */ >>> Maybe it would be cleaner to use something like: >> >> I actually considered all of these and ended up with a raw number >> because it seems to be a convention in kernel (and Xen too, apparently) >> to use raw values in .S files. >> >> Kernel is using now GDT_ENTRY_INIT() which is a C macro. There is one >> other location where GDT_INIT() is used (arch/x86/boot/pm.c) and, >> incidentally, it also generates this warning IIRC. >> >> I really don't want to move definition to C code just to use a macro --- >> I don't think C code needs to be exposed to this GDT. >> >> >>> >>> .word 0xffff /* limit */ >>> .word 0 /* base */ >>> .byte 0 /* base */ >>> .byte 0x9a /* access */ >>> #ifdef CONFIG_X86_64 >>> .byte 0xaf /* flags plus limit */ >>> #else >>> .byte 0xcf /* flags plus limit */ >>> #endif >>> .byte 0 /* base */ >> >> >> I, in fact, started with something like this. But if you repeat this 4 >> times you will probably see why I decided against it ;-) > > Heh, right. Maybe a .macro to generate those? Or this is all too much > for just a couple of GDT entries anyway... That's what I thought. Especially given that assembly code seems to be using raw values. > > For long mode however you could use simpler values, AFAICT the code > segment in long mode could be simplified to: > > 0x00209a0000000000 > > Because the base/limit have no effect. True. However, we are sharing the DS (and later GS) descriptors between 32- and 64-it modes. I can separate them if you think it makes sense. -boris > > In any case I'm not specially inclined either way, and maybe using > similar values for 32 and 64bit modes makes this easier to understand > (and decode if needed). > > Roger. >