Received: by 10.192.165.148 with SMTP id m20csp4652228imm; Tue, 1 May 2018 00:54:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpS4yOyZ0Dp/g9Rvqdiu8NbsR50gah8xxivKgBSUjtaM/c/5cU905JuyYlUZQqU374ixGaZ X-Received: by 2002:a17:902:5a0d:: with SMTP id q13-v6mr15172989pli.199.1525161269791; Tue, 01 May 2018 00:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525161269; cv=none; d=google.com; s=arc-20160816; b=P7QthJDOXH6GtxNGwdJQgiOf4yZRosLwxahROkHpu0ANo2enjLCXqWWhZcKascrr06 RMYg69xx4JAiiSoTAOGtjhR1mWUpY1JHM+2awxte8dgsc4NkQ6UPO9t/+bcvOqB8F+NZ 3uduW+iFJYje0viOWoOg4qFjAtyR7Mttgpd3jGp+HeUnWMlj/Xz6+7UY5OPFqituucdB mcxmGupxG3X7oD0kgJ77QSmvVOjaYG4iOPiFTQzV7z+Is1jQatHA4MefRZAc89zEU52x BOzg3B68dipMVi8R9WoBD5j02RkttZc961IPy8/M2aEKiZivsuertWU8p/AVRq3stbft HnRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=fN2L8eiG+zx8FLTD67z+6iCTtzDYJSh/WhuZAsWCLqo=; b=gpe0YZ0IHAxNnEbr1apjEWp5OwoBlZ1mF2ChcOe0tkas9SFRd1MLT4t4t0bUsrIRRC oUaoyS0jG3asMtd8PhuLmef54SyA11kwt1uF7kLFACUY/iY8niUjWAv7QY2Ec5DSAVm1 AKRdpAtV9UZPIGhjdyBCcOBfqfBkFSEB7MEb0uobwNFMMEZvmq4tjOxhH6VSee5gFuua lDtB0Y041yIflPvMMqAbXsm9h8EoQuS6/3mGLVN+M7ES+5P4GS1oXBPhfmMo9VKnn4ww u0smg+5xFUGQOmhk/Pr+ZhMIqsej5dpqbyYUuXLOeERI1hu+UICKp5nWx40owlS78E4/ zqLg== 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 y21-v6si9277022plr.314.2018.05.01.00.54.15; Tue, 01 May 2018 00:54:29 -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; 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 S1752131AbeEAHyD (ORCPT + 99 others); Tue, 1 May 2018 03:54:03 -0400 Received: from smtp.eu.citrix.com ([185.25.65.24]:11361 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751071AbeEAHyB (ORCPT ); Tue, 1 May 2018 03:54:01 -0400 X-IronPort-AV: E=Sophos;i="5.49,350,1520899200"; d="scan'208";a="72417676" Date: Tue, 1 May 2018 08:53:52 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Boris Ostrovsky CC: , , , Subject: Re: [Xen-devel] [PATCH 1/4] xen/PVH: Replace GDT_ENTRY with explicit constant Message-ID: <20180501075352.ffx5dqaedo657nub@MacBook-Pro-de-Roger.local> 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> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <310676e9-d527-421b-a367-a6a8ada5255d@oracle.com> User-Agent: NeoMutt/20180323 X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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... 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. 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.