From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by sourceware.org (Postfix) with ESMTPS id EABD6385781B for ; Tue, 29 Sep 2020 16:27:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EABD6385781B Received: from AM6P195CA0018.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::31) by DBAPR08MB5557.eurprd08.prod.outlook.com (2603:10a6:10:1a1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.24; Tue, 29 Sep 2020 16:27:36 +0000 Received: from VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:81:cafe::e1) by AM6P195CA0018.outlook.office365.com (2603:10a6:209:81::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22 via Frontend Transport; Tue, 29 Sep 2020 16:27:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT048.mail.protection.outlook.com (10.152.19.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.21 via Frontend Transport; Tue, 29 Sep 2020 16:27:35 +0000 Received: ("Tessian outbound e8cdb8c6f386:v64"); Tue, 29 Sep 2020 16:27:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 00cff410180e688d X-CR-MTA-TID: 64aa7808 Received: from 0b9e33f31cd3.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7DBE031F-5975-4594-A91B-A5759EE32C32.1; Tue, 29 Sep 2020 16:27:27 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0b9e33f31cd3.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 29 Sep 2020 16:27:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PE04PTNWRKFYVL0emA1JJ1pdCwmdevDbXp/gXxV1D0umlzktoEPKmiM73a8Kviv8ucjZC3fe7e9FwFVXvQSihEf+yOzJyWe1CD2ZAEuyiqWLUlMgPbQ8hPmgPzOlKx/1jp2U1XLL1X0b2x2U6aDmdylmQaea+5VSqpRIQ6WMq9GaYGasWFU9FJUYqDAuoROUtMRj+/sUJgCRTqNNgFXWx1zLS3mA7rOHTm01sRxXCfC4aP0uSqcfByIlR318QGBac2/n1cteBed9wwx4ga8SUnMUCRjqQqTuRA35gAOrIIx5sjtCpZL2Db4CskVCLrw6Y2UULAYN2ielLYmNn9s7qQ== 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-SenderADCheck; bh=tsXcjQMovJrqDA6PKZGZMrY9PXVpWXZ10c+UQp3eP+k=; b=HQO8q7F3/EfhzKwyCCOTGOFyVf+lFFRhsUImlvCjxwYfLn84i+BCMzUw1eRIc3LzmGd6dLYX5Wll3sVYQ3iIOXAJ/tLWNn8a7VYVnraVR2tnNkSIxfQC1RxUyjjL6WPHWFWViwzSkP6VtP1xLRkDETR3xOwB3ehCcIP04y1aEr8fYxyHS4QZJ0kWihHrBjYXu/Y9IU11rHudHptHZ+FEjdQVJycZoqLU8G9MW6pqsOezYL53RLBBgArgL9zZQ1Xf+jX/cbOZoiEO6IKHMwnYTwjf30V6t/BepeHEQXpObcvcfJ5r8BW0xqURKGWWPd7FmYUQiJ7QlAAaqdwPxhObcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) by VI1PR08MB3920.eurprd08.prod.outlook.com (2603:10a6:803:c2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Tue, 29 Sep 2020 16:27:25 +0000 Received: from VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::c194:c7c6:f09e:6f3d]) by VI1PR08MB4029.eurprd08.prod.outlook.com ([fe80::c194:c7c6:f09e:6f3d%7]) with mapi id 15.20.3412.029; Tue, 29 Sep 2020 16:27:25 +0000 Date: Tue, 29 Sep 2020 17:27:18 +0100 From: Alex Coplan To: "Richard Earnshaw (lists)" Cc: newlib@sourceware.org Subject: Re: [PATCH] libgloss/aarch64: Add support for Armv8-R AArch64 Message-ID: <20200929162718.x2s3w2pfnelxkzkr@arm.com> References: <20200918144327.7qgh64f57myg6njs@arm.com> <0bdab8d7-67ee-0d61-3e80-1b8365c41204@arm.com> Content-Type: multipart/mixed; boundary="xccr7w7iaqwttmrl" Content-Disposition: inline In-Reply-To: <0bdab8d7-67ee-0d61-3e80-1b8365c41204@arm.com> User-Agent: NeoMutt/20171215 X-ClientProxiedBy: SA9PR03CA0006.namprd03.prod.outlook.com (2603:10b6:806:20::11) To VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.52) by SA9PR03CA0006.namprd03.prod.outlook.com (2603:10b6:806:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.24 via Frontend Transport; Tue, 29 Sep 2020 16:27:24 +0000 X-Originating-IP: [217.140.106.52] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 201cc05c-a398-4647-5e55-08d8649492f2 X-MS-TrafficTypeDiagnostic: VI1PR08MB3920:|DBAPR08MB5557: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3383;OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 5u+ZZ0m+rvPzSRqWq5My7UbyuYeyXNY7po0aRCmGjC3AcxIS+cnl8vABela6Eum3cpkeaitRBQAUjd/TPU2p2vUX/Kls2joYkji9TEbpf5m2Vfr9zRvWwogB3PO4mMyuu9WAmNJSNT6zPO47CIobNa2tdqltiSuDy34SCSGJzWHTuFARkh/HllztP3IDWSoqKTQWBSfy7SNf52MM6bnxu3oEhT7Pv+NgJwB+P08LD7sAvXLcQiDe8UTIIFvWsy/2ehkscSNkEQssEJnlv26ohXiH6yeehECIRIVG3yrx7tLDCLY+psN8O7TUVxCa4dm6LklahCSXWbAy/IBPuBoxQHaD8ibvWFaSdvjhJDBvGRL0fuzTuJEj+MXoHZ28jburiY9Wr2AJ4CWa6SnxX6ZXPggUGWGFfQpbXCK5XK/1KIc= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB4029.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(366004)(136003)(396003)(39860400002)(66616009)(83380400001)(66946007)(8886007)(4326008)(86362001)(36756003)(8936002)(1076003)(235185007)(37006003)(5660300002)(6862004)(316002)(55016002)(6666004)(52116002)(66556008)(2616005)(8676002)(44832011)(956004)(33964004)(44144004)(6636002)(66476007)(478600001)(16526019)(53546011)(26005)(186003)(7696005)(2906002)(21490400003)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tprtrFXALq1EiSmh93V5UvM7UacoRshF8izjuXr9sZ1vj9GdiuGvXMrRu2+6dG/VOrSh8jStGP+6OPb1Ar0/pUZxKQoAtTf5zIe16wG6E8C0BTkFcRKhlDwjKec48VoWdUfD0eGYY+Y17P2VgfBr4L3l2ZBMu2oiB9aJrKIsSfTBul8deMnLFgaWcCzjvR+c5AvgdYMcJdcMdGRtYGE+yWT/yXpFKDV8O3/LqFbIU+IfHZ6LJqSoouy+VLovDRvFhaL/T9XfY9e7tBTD3kuvvfaGu4d24bitvUzr8+b2fVNMiamI3ifkTME+D8/34EGfRSWp5aV5KTGQXJEUbY+7xJgxNsx7BHsXUp70YQxUymmWDA1PRCQeH+UL8xGcJys2WuBfe7Yt5sTVMy+zX42Z4U6oTcPJApJqTLYoFTpjxyEpE+AwBfj6ksNmD4WK1AyIyRe4XCuZXeClQ31VAvqqFBQaaqmlePrPXrZCLjiDPdXl/h7K2nxku8oaynyLM1QMSEYP9DuuxjIFKRDX9TBHZMuxJv2c1u2uCL1ZCrTKWVFTr9Nj+Qyx6KkgcDmop/7NY5E4cuJq67GEonxJTUe97ki/UeKphln9ftcoiCgrdjjrbaMUs3cqlWN4JP2cNmETNdw0/qb74KpfND7QWEektw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3920 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bb60bdd0-3894-4879-edd8-08d864948cf5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y8nGp1Nnlp7BdBjrOXJUMYh0GN18C9C0uOUF/+qirucClxIG4UJUZBCP5k1EX006yYqE7XWu+b+QelQXOcDSZDlLNUDzSHt/us5XmOSZNVUWZEYOlnAylAUi5xn11YFLjgU3+6k/DOwMXBQRD+85NEWs2pIXKKKV1Q9dO4MtoAmEDt8nYfnhFblMqq98cEJbACK6/0CGiESqz8AP8Af6NYo5zoU7ODYgCK63kntC7V9tJ2llmFDNQSN3oJRwd0Am4OyT39b2x3hpAMROygPN0jDpzHXDDxvBuy+K5vkYT9tx//iTay/rKtakw+HVfTgH5PXhbhzwhSJTdM9ODZN36rpJ1r+E/ORD7AGXosSYVgpzXkiWeqvhJqDZHRKjM/Xp8ytoHgI24PWE/ve8K7pViE6oUq89FtNrXgj7Dkz7VQ1RRoz7ESm26kYMXu+7RdDk9riR84jE5WhWiEf1z/BWgBHW9fhen4453T/3i1S8TCI= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(136003)(39860400002)(376002)(396003)(346002)(46966005)(55016002)(356005)(86362001)(8886007)(6636002)(5660300002)(36756003)(2906002)(8936002)(478600001)(235185007)(81166007)(956004)(336012)(83380400001)(186003)(82310400003)(16526019)(2616005)(8676002)(36906005)(1076003)(47076004)(82740400003)(6862004)(44144004)(33964004)(6666004)(7696005)(53546011)(316002)(21490400003)(4326008)(66616009)(44832011)(70206006)(70586007)(26005)(37006003)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2020 16:27:35.5100 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 201cc05c-a398-4647-5e55-08d8649492f2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5557 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_NUMSUBJECT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2020 16:27:40 -0000 --xccr7w7iaqwttmrl Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hi Richard, On 29/09/2020 15:06, Richard Earnshaw (lists) wrote: > On 18/09/2020 15:43, Alex Coplan wrote: > > Hello, > > > > This patch adds support for Armv8-R AArch64. We update the AArch64 CPU > > boot code to work on Armv8-R if __ARM_ARCH_PROFILE is set to 'R'. > > Armv8-R AArch64 has no EL3, so we don't set vbar_el3, and adjust the > > code to set up the MPU for Armv8-R. > > > > We also add a specs file for use with Armv8-R AArch64 models. > > > > Testing: > > * Ran AArch64 GCC testsuite using --with-arch=armv8-r together with the > > new specs file and boot code in an Armv8-R AArch64 model. > > * Ran newlib testsuite, no regressions. > > > > OK for master? > > > > Thanks, > > Alex > > > > --- > > > > 2020-09-18 Alex Coplan > > > > libgloss/ChangeLog: > > > > * aarch64/Makefile.in: Install new specs file. > > * aarch64/cpu-init/Makefile.in: Also build boot code for Armv8-R. > > * aarch64/cpu-init/rdimon-aem-el3.S: Add support for Armv8-R. > > * aarch64/elf-aem-v8-r.specs: New. > > > > The main problem I see with this is that it assumes that the compiler > being used is *not* configured for a default CPU architecture of > ARMv8-r. If it is, then the normal rdimon-aem-el3.o file will in fact > become the same as the v8-r version, which is not really what we want. Good catch. Thanks for the review. > > Perhaps, rather than hacking around the __ARM_ARCH_PROFILE setting you > should just set things up to build the file twice, but with a different > conventional pre-define set each time. > > R. Sounds sensible. Is the revised patch (attached) OK? Thanks, Alex --xccr7w7iaqwttmrl Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v2.diff" diff --git a/libgloss/aarch64/Makefile.in b/libgloss/aarch64/Makefile.in index 546557e3c..b8c2ca43c 100644 --- a/libgloss/aarch64/Makefile.in +++ b/libgloss/aarch64/Makefile.in @@ -85,7 +85,8 @@ RDIMON_BSP = librdimon${${MULTILIBNAME}}.a RDIMON_OBJS = $(patsubst %,rdimon-%,$(OBJS)) RDIMON_SCRIPTS = rdimon${${MULTILIBNAME}}.specs \ aem-ve${${MULTILIBNAME}}.specs \ - aem-validation${${MULTILIBNAME}}.specs + aem-validation${${MULTILIBNAME}}.specs \ + aem-v8-r${${MULTILIBNAME}}.specs RDIMON_INSTALL = install-rdimon CFLAGS = -g diff --git a/libgloss/aarch64/cpu-init/Makefile.in b/libgloss/aarch64/cpu-init/Makefile.in index 08aa1760f..c96f4ee0e 100644 --- a/libgloss/aarch64/cpu-init/Makefile.in +++ b/libgloss/aarch64/cpu-init/Makefile.in @@ -62,7 +62,7 @@ AR = @AR@ LD = @LD@ RANLIB = @RANLIB@ -CPU_INIT_OBJS = rdimon-aem-el3.o +CPU_INIT_OBJS = rdimon-aem-el3.o rdimon-aem-v8-r.o CPU_INIT_INSTALL = install-cpu-init CFLAGS = -g @@ -79,10 +79,12 @@ all: ${CPU_INIT_OBJS} .PHONY: test test: -# Static pattern rule for assembling cpu init files to object files. -${CPU_INIT_OBJS}: %.o: %.S +rdimon-aem-el3.o : rdimon-aem-el3.S $(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $< +rdimon-aem-v8-r.o : rdimon-aem-el3.S + $(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -DBUILD_FOR_R_PROFILE -o $@ -c $< + clean mostlyclean: rm -f a.out core *.i *.o *-test *.srec *.dis *.x diff --git a/libgloss/aarch64/cpu-init/rdimon-aem-el3.S b/libgloss/aarch64/cpu-init/rdimon-aem-el3.S index e00f0b2c8..0296a8054 100644 --- a/libgloss/aarch64/cpu-init/rdimon-aem-el3.S +++ b/libgloss/aarch64/cpu-init/rdimon-aem-el3.S @@ -43,7 +43,9 @@ _init_vectors: /* Installs a table of exception vectors to catch and handle all exceptions by terminating the process with a diagnostic. */ adr x0, vectors +#ifndef BUILD_FOR_R_PROFILE msr vbar_el3, x0 +#endif msr vbar_el2, x0 msr vbar_el1, x0 ret @@ -110,6 +112,14 @@ vectors: .text .align 2 _flat_map: +#ifdef BUILD_FOR_R_PROFILE + mrs x0, sctlr_el2 + orr x0, x0, #1 // SCTLR_EL2.M (enable MPU) + orr x0, x0, #(1 << 17) // SCTLR_EL2.BR (background regions) + msr sctlr_el2, x0 + isb + ret +#else /* Page table setup (identity mapping). */ adrp x0, ttb add x0, x0, :lo12:ttb @@ -173,6 +183,7 @@ _flat_map: isb .Lnosve: ret +#endif .data .align 12 diff --git a/libgloss/aarch64/elf-aem-v8-r.specs b/libgloss/aarch64/elf-aem-v8-r.specs new file mode 100644 index 000000000..4daeffd11 --- /dev/null +++ b/libgloss/aarch64/elf-aem-v8-r.specs @@ -0,0 +1,20 @@ +# elf-aem-v8-r.specs +# +# Spec file for AArch64 baremetal newlib, libgloss on Armv8-R with version 2 of +# AngelAPI semi-hosting. + +%rename link old_link + +*link: +-Ttext-segment 0x10000 %(old_link) + +%rename lib libc + +*libgloss: +-lrdimon + +*lib: +cpu-init/rdimon-aem-v8-r.o%s --start-group %(libc) %(libgloss) --end-group + +*startfile: +crti%O%s crtbegin%O%s %{!pg:rdimon-crt0%O%s} %{pg:rdimon-crt0%O%s} --xccr7w7iaqwttmrl--