[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1] xen/riscv: make calculation of stack address PC-relative


  • To: Oleksii <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 16 Mar 2023 09:34:21 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1c5FVRhNzAiNy4LVaNatua8+smXZRblsdmTxCuZOdiQ=; b=FJlYL8o3ixqc243nit8R7atTSNUJnRwu7m6YR7fudy4pzshl/i10m+hsVmmHDDGTd/mmgbThgX3AjB9HypdvM+UQWcmjc2/2ok+vgwy07PmJjMGR8Dkc8/8hTVbzrnDuacbZ75ea4T3+Xq2vrv4mdUZ1NzNZZpH7lexhmlFq9cBPDXoYf4v54DsAHL+Gep8zF7yF5UVOli0136/E74UQRS3faNqFe9BQX/f+modY7ys4tydyJvgGs+159GdHWDrA5z4vpK9tqgm7fE3KTfSJYrlHJBlZ/y8qGhmIC31HJfpQRAF9QuOwBUdsfxhx3iJfptj9IDXDFNdcD+YoWzF26Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4UdGw++7KBdLMAlMud12utVsUi9mQD4v/JNvNtHnDtK7eTh5YzQNRCe8NmBrS4WE49befyBKPJDMDllhIE2eLfPJ7QTnHo/Hnl4ejCG18wV+nWEsOnfQNoyLxt8dNGCYSvwBJ7/FRwoaIPRluU3tRw1AQhf169oceH6bhGNZyjJccIXF6brvPd4z0Mi8JXkz7gSDd2d0zRBsDIfpnMWEKGqUlnICNMRCMDfZgAM+/1pvdKzgHnrOwD1o5UUYEx/9V49wQ0z+9QyOQXSpHG4SU5SLlaUDxxqtcjsVBdySE0cYzmL0TJaYT69qQSUqTcTY07qpthVqatlcScIktWJ9Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Gianluca Guida <gianluca@xxxxxxxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 16 Mar 2023 08:34:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15.03.2023 19:23, Oleksii wrote:
> On Wed, 2023-03-15 at 08:59 +0100, Jan Beulich wrote:
>> On 14.03.2023 21:16, Oleksii wrote:
>>> I checked in Linux binary how 'la' instruction is transformed, and
>>> it
>>> looks like it is translated as I expect to auipc/addi pair:
>>> ffffffe000001066: 00027517 auipc a0,0x27
>>> ffffffe00000106a: f9a50513 addi a0,a0,-102 # ffffffe000028000
>>> <early_pg_dir>
>>>
>>> I checked compiler flags between Xen and Linux. The difference is
>>> in-
>>> fno-PIE (Linux also adds -mabi and -march to AFLAGS):
>>>
>>> 1. Linux build command of head.S: riscv64-linux-gnu-gcc -Wp,-
>>> MD,arch/riscv/kernel/.head.o.d -nostdinc -isystem /usr/lib/gcc-
>>> cross/riscv64-linux-gnu/9/include -I./arch/riscv/include -
>>> I./arch/riscv/include/generated -I./include -
>>> I./arch/riscv/include/uapi
>>> -I./arch/riscv/include/generated/uapi -I./include/uapi -
>>> I./include/generated/uapi -include ./include/linux/kconfig.h -
>>> D__KERNEL__ -D__ASSEMBLY__ -fno-PIE -mabi=lp64 -march=rv64imafdc -c
>>> -o
>>> arch/riscv/kernel/head.o arch/riscv/kernel/head.S
>>>
>>> 2. Xen build command of head.S:riscv64-linux-gnu-gcc -MMD -MP -MF
>>> arch/riscv/riscv64/.head.o.d -D__ASSEMBLY__ -Wa,--noexecstack -
>>> DBUILD_ID -fno-strict-aliasing -Wall -Wstrict-prototypes -
>>> Wdeclaration-
>>> after-statement -Wno-unused-but-set-variable -Wno-unused-local-
>>> typedefs
>>> -O1 -fno-omit-frame-pointer -nostdinc -fno-builtin -fno-common -
>>> Werror
>>> -Wredundant-decls -Wno-pointer-arith -Wvla -pipe -D__XEN__ -include
>>> ./include/xen/config.h -Wa,--strip-local-absolute -g -mabi=lp64 -
>>> I./include -I./arch/riscv/include -march=rv64gc -mstrict-align -
>>> mcmodel=medany - -c arch/riscv/riscv64/head.S -o
>>> arch/riscv/riscv64/head.o
>>
>> Looking into why you see different code generated than I: Nothing in
>> here directs gcc to pass -fpic to gas; in upstream gcc (consistent
>> from gcc7 through gcc12, which are the versions I've checked; the
>> actual range may be wider) there is
>>
>> #define ASM_SPEC "\
>> %(subtarget_asm_debugging_spec) \
>> %{" FPIE_OR_FPIC_SPEC ":-fpic} \
>> ...
>>
>> Can you check whether your gcc passes -fpic to gas even when there's
>> no -fPIC / -fPIE (or alike) on the gcc command line?
> I am not sure that I know how to check specifically if -fpic flag
> passes to gas.
> Could you please tell me?

Just to answer this question here (the other aspect fit better elsewhere):
You can pass -v to gcc to make it report what options it invokes other
tools (including gas) with.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.