From nobody Thu May 16 18:34:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677251228; cv=none; d=zohomail.com; s=zohoarc; b=hWvLkVLjU5PiqhTY3GmgHiJ1+V8MH2yL9wCzbWm7+AZSB7guoBGXxiyBoQocFF2L1gaqpK0T8846wQ8kmQzwgoWgidHnLsroSzIS69frC1nydSofimcW5WKh/NSv6LM2E8dys+OqVfxZMEhuKUdGGxOVzzhy868zxQvkrsFNh2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677251228; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gXawhnE5jkqhZOoZruY5CrZc+i29kTMYxJVObGHfjMI=; b=iPR0hDEFoa+kohFyE2sv9WwrNDKh29ZO0wCdTXNklRnb2fn7gRC5swW7ZPyg1EtClxlFMj0evbwvKAq90JyHcCOxCDncc7A+YmyALG0gf0w/KgrtrAMNOdH4/ILzXh2bgvU3At6fGgj17KAvHUNJ7hbQdN9wuA7K7asmPr5U5qU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677251228458372.39613761752344; Fri, 24 Feb 2023 07:07:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.501138.772756 (Exim 4.92) (envelope-from ) id 1pVZel-0006eX-Ir; Fri, 24 Feb 2023 15:06:43 +0000 Received: by outflank-mailman (output) from mailman id 501138.772756; Fri, 24 Feb 2023 15:06:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pVZel-0006eQ-FE; Fri, 24 Feb 2023 15:06:43 +0000 Received: by outflank-mailman (input) for mailman id 501138; Fri, 24 Feb 2023 15:06:42 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pVZek-0006Ou-Lj for xen-devel@lists.xenproject.org; Fri, 24 Feb 2023 15:06:42 +0000 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [2a00:1450:4864:20::12a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d85a0d9d-b454-11ed-88bb-e56d68cac8db; Fri, 24 Feb 2023 16:06:41 +0100 (CET) Received: by mail-lf1-x12a.google.com with SMTP id k14so17292450lfj.7 for ; Fri, 24 Feb 2023 07:06:41 -0800 (PST) Received: from 34-6F-24-FC-D2-65.. (46.204.108.92.nat.umts.dynamic.t-mobile.pl. [46.204.108.92]) by smtp.gmail.com with ESMTPSA id d23-20020ac25457000000b004d863fa8681sm1492443lfn.173.2023.02.24.07.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 07:06:40 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d85a0d9d-b454-11ed-88bb-e56d68cac8db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gXawhnE5jkqhZOoZruY5CrZc+i29kTMYxJVObGHfjMI=; b=Cu5oxsw7VJsw/LxVADe9BvwNUZR4vaXCU4C2+tIt4O2iPhdW76P3bb0wtbdl2QXB7/ wlFhr7JuYwZExbKAfDBco+cFcNpGaAaZZbgnSd77ibALk0nZ/SYB496Gsh46uEMBgfGa hAbY2Mn6cTVUoW2sgOMtvQ0m8D7A2PSDODsfv0U5TjBCWjVpQCbqPDVrm2QfkLa2xdd3 CI8mvdLCODbKNwyFfstHs4PA6DG+rmgXPH0iGBXDeZxzRmAn6wC+5OrKKavDl085Lm2V FaFnACEiqndlnyvg6YQRFVSc7SuQN9+Ep7WQpORuR3AlI/9IuL0ZeMfpRar5qmXtyt2h 91pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gXawhnE5jkqhZOoZruY5CrZc+i29kTMYxJVObGHfjMI=; b=Dqp/tX72vmeOwxm2jVoi13yBCMPQEaclcUYwxp8CAhsi+XrW/RmRuLi6qCLhrOKYRj vur4VwyDUvQUo7DJzodHeZKUp9rx74GERuz3DTIzOI81xIlTmDu05yPp4oE/ZdKDtosO G8oDczrJigRPQPJO+21X+SRdmQar/7bWICQa+JNBgG8qXXFYWFLoHuxd9HKginID2C0U ZNM0gCjzawUbyt+PDi8jbUIM4IWj6XVH7waQC0gvxIjMw/8PwOJVTR4iGyLXzVaKMXMR g1mlIGsABOoR0zZR4giCMUvjgWkt7fDND2iGrd8ndD6SGOpy6ihRm3n57fBQ6qHQqIQZ p/EQ== X-Gm-Message-State: AO0yUKVjsziUwrNvE8qs3/IU2W/alCjS8qvSLP9LzfyDzAxQXStKvQiT TZOw4eRD3Co0a8u2GQg2HK9IYUxlvC4= X-Google-Smtp-Source: AK7set86tEFDgJknJHgH2TlaUlv4gl/KdDVxTIX/gEUSUMZtLJNIBzmst4hjSM6Kwvax+5AsBN5fGA== X-Received: by 2002:ac2:59d9:0:b0:4dc:260e:6b59 with SMTP id x25-20020ac259d9000000b004dc260e6b59mr5945954lfn.40.1677251201252; Fri, 24 Feb 2023 07:06:41 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v1 1/3] xen/riscv: introduce setup_initial_pages Date: Fri, 24 Feb 2023 17:06:33 +0200 Message-Id: X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677251230219100001 Content-Type: text/plain; charset="utf-8" Mostly the code for setup_initial_pages was taken from Bobby's repo except for the following changes: * Use only a minimal part of the code enough to enable MMU * rename {_}setup_initial_pagetables functions * add writable argument for _setup_initial_pagetables to have an opportunity to make some sections read-only * update setup_initial_pagetables function to make some sections read-only * change the order of _setup_inital_pagetables() in setup_initial_pagetable(): * first it is called for text, init, rodata sections * after call it for ranges [link_addr_start : link_addr_end] and [load_addr_start : load_addr_end] Before it was done first for the ranges and after for sections but in that case read-only status will be equal to 'true' and as sections' addresses can/are inside the ranges the read-only status won't be updated for them as it was set up before. Origin: https://gitlab.com/xen-on-risc-v/xen/-/tree/riscv-rebase 4af165b468= af Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/include/asm/mm.h | 9 ++ xen/arch/riscv/include/asm/page.h | 90 ++++++++++++ xen/arch/riscv/mm.c | 223 ++++++++++++++++++++++++++++++ 4 files changed, 323 insertions(+) create mode 100644 xen/arch/riscv/include/asm/mm.h create mode 100644 xen/arch/riscv/include/asm/page.h create mode 100644 xen/arch/riscv/mm.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 443f6bf15f..956ceb02df 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_EARLY_PRINTK) +=3D early_printk.o obj-y +=3D entry.o +obj-y +=3D mm.o obj-$(CONFIG_RISCV_64) +=3D riscv64/ obj-y +=3D sbi.o obj-y +=3D setup.o diff --git a/xen/arch/riscv/include/asm/mm.h b/xen/arch/riscv/include/asm/m= m.h new file mode 100644 index 0000000000..fc1866b1d8 --- /dev/null +++ b/xen/arch/riscv/include/asm/mm.h @@ -0,0 +1,9 @@ +#ifndef _ASM_RISCV_MM_H +#define _ASM_RISCV_MM_H + +void setup_initial_pagetables(unsigned long load_addr_start, + unsigned long load_addr_end, + unsigned long linker_addr_start, + unsigned long linker_addr_end); + +#endif /* _ASM_RISCV_MM_H */ diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm= /page.h new file mode 100644 index 0000000000..fabbe1305f --- /dev/null +++ b/xen/arch/riscv/include/asm/page.h @@ -0,0 +1,90 @@ +#ifndef _ASM_RISCV_PAGE_H +#define _ASM_RISCV_PAGE_H + +#include +#include + +#define PAGE_ENTRIES 512 +#define VPN_BITS (9) +#define VPN_MASK ((unsigned long)((1 << VPN_BITS) - 1)) + +#ifdef CONFIG_RISCV_64 +/* L3 index Bit[47:39] */ +#define THIRD_SHIFT (39) +#define THIRD_MASK (VPN_MASK << THIRD_SHIFT) +/* L2 index Bit[38:30] */ +#define SECOND_SHIFT (30) +#define SECOND_MASK (VPN_MASK << SECOND_SHIFT) +/* L1 index Bit[29:21] */ +#define FIRST_SHIFT (21) +#define FIRST_MASK (VPN_MASK << FIRST_SHIFT) +/* L0 index Bit[20:12] */ +#define ZEROETH_SHIFT (12) +#define ZEROETH_MASK (VPN_MASK << ZEROETH_SHIFT) + +#else // CONFIG_RISCV_32 + +/* L1 index Bit[31:22] */ +#define FIRST_SHIFT (22) +#define FIRST_MASK (VPN_MASK << FIRST_SHIFT) + +/* L0 index Bit[21:12] */ +#define ZEROETH_SHIFT (12) +#define ZEROETH_MASK (VPN_MASK << ZEROETH_SHIFT) +#endif + +#define THIRD_SIZE (1 << THIRD_SHIFT) +#define THIRD_MAP_MASK (~(THIRD_SIZE - 1)) +#define SECOND_SIZE (1 << SECOND_SHIFT) +#define SECOND_MAP_MASK (~(SECOND_SIZE - 1)) +#define FIRST_SIZE (1 << FIRST_SHIFT) +#define FIRST_MAP_MASK (~(FIRST_SIZE - 1)) +#define ZEROETH_SIZE (1 << ZEROETH_SHIFT) +#define ZEROETH_MAP_MASK (~(ZEROETH_SIZE - 1)) + +#define PTE_SHIFT 10 + +#define PTE_VALID BIT(0, UL) +#define PTE_READABLE BIT(1, UL) +#define PTE_WRITABLE BIT(2, UL) +#define PTE_EXECUTABLE BIT(3, UL) +#define PTE_USER BIT(4, UL) +#define PTE_GLOBAL BIT(5, UL) +#define PTE_ACCESSED BIT(6, UL) +#define PTE_DIRTY BIT(7, UL) +#define PTE_RSW (BIT(8, UL) | BIT(9, UL)) + +#define PTE_LEAF_DEFAULT (PTE_VALID | PTE_READABLE | PTE_WRITABLE |= PTE_EXECUTABLE) +#define PTE_TABLE (PTE_VALID) + +/* Calculate the offsets into the pagetables for a given VA */ +#define zeroeth_linear_offset(va) ((va) >> ZEROETH_SHIFT) +#define first_linear_offset(va) ((va) >> FIRST_SHIFT) +#define second_linear_offset(va) ((va) >> SECOND_SHIFT) +#define third_linear_offset(va) ((va) >> THIRD_SHIFT) + +#define pagetable_zeroeth_index(va) zeroeth_linear_offset((va) & ZEROETH_M= ASK) +#define pagetable_first_index(va) first_linear_offset((va) & FIRST_MASK) +#define pagetable_second_index(va) second_linear_offset((va) & SECOND_MAS= K) +#define pagetable_third_index(va) third_linear_offset((va) & THIRD_MASK) + +/* Page Table entry */ +typedef struct { + uint64_t pte; +} pte_t; + +/* Shift the VPN[x] or PPN[x] fields of a virtual or physical address + * to become the shifted PPN[x] fields of a page table entry */ +#define addr_to_ppn(x) (((x) >> PAGE_SHIFT) << PTE_SHIFT) + +static inline pte_t paddr_to_pte(unsigned long paddr) +{ + return (pte_t) { .pte =3D addr_to_ppn(paddr) }; +} + +static inline bool pte_is_valid(pte_t *p) +{ + return p->pte & PTE_VALID; +} + +#endif /* _ASM_RISCV_PAGE_H */ diff --git a/xen/arch/riscv/mm.c b/xen/arch/riscv/mm.c new file mode 100644 index 0000000000..6e172376eb --- /dev/null +++ b/xen/arch/riscv/mm.c @@ -0,0 +1,223 @@ +#include +#include + +#include +#include +#include + +/* + * xen_second_pagetable is indexed with the VPN[2] page table entry field + * xen_first_pagetable is accessed from the VPN[1] page table entry field + * xen_zeroeth_pagetable is accessed from the VPN[0] page table entry field + */ +pte_t xen_second_pagetable[PAGE_ENTRIES] __attribute__((__aligned__(PAGE_S= IZE))); +static pte_t xen_first_pagetable[PAGE_ENTRIES] + __attribute__((__aligned__(PAGE_SIZE))); +static pte_t xen_zeroeth_pagetable[PAGE_ENTRIES] + __attribute__((__aligned__(PAGE_SIZE))); + +extern unsigned long _stext; +extern unsigned long _etext; +extern unsigned long __init_begin; +extern unsigned long __init_end; +extern unsigned long _srodata; +extern unsigned long _erodata; + +paddr_t phys_offset; + +#define resolve_early_addr(x) \ + ({ = \ + unsigned long * __##x; = \ + if ( load_addr_start <=3D x && x < load_addr_end ) = \ + __##x =3D (unsigned long *)x; = \ + else = \ + __##x =3D (unsigned long *)(x + load_addr_start - linker_addr_= start); \ + __##x; = \ + }) + +static void __init clear_pagetables(unsigned long load_addr_start, + unsigned long load_addr_end, + unsigned long linker_addr_start, + unsigned long linker_addr_end) +{ + unsigned long *p; + unsigned long page; + unsigned long i; + + page =3D (unsigned long)&xen_second_pagetable[0]; + + p =3D resolve_early_addr(page); + for ( i =3D 0; i < ARRAY_SIZE(xen_second_pagetable); i++ ) + { + p[i] =3D 0ULL; + } + + page =3D (unsigned long)&xen_first_pagetable[0]; + p =3D resolve_early_addr(page); + for ( i =3D 0; i < ARRAY_SIZE(xen_first_pagetable); i++ ) + { + p[i] =3D 0ULL; + } + + page =3D (unsigned long)&xen_zeroeth_pagetable[0]; + p =3D resolve_early_addr(page); + for ( i =3D 0; i < ARRAY_SIZE(xen_zeroeth_pagetable); i++ ) + { + p[i] =3D 0ULL; + } +} + +/* + * WARNING: load_addr() and linker_addr() are to be called only when the M= MU is + * disabled and only when executed by the primary CPU. They cannot refer = to + * any global variable or functions. + */ + +/* + * Convert an addressed layed out at link time to the address where it was= loaded + * by the bootloader. + */ +#define load_addr(linker_address) = \ + ({ = \ + unsigned long __linker_address =3D (unsigned long)(linker_address)= ; \ + if ( linker_addr_start <=3D __linker_address && = \ + __linker_address < linker_addr_end ) = \ + { = \ + __linker_address =3D = \ + __linker_address - linker_addr_start + load_addr_start; = \ + } = \ + __linker_address; = \ + }) + +/* Convert boot-time Xen address from where it was loaded by the boot load= er to the address it was layed out + * at link-time. + */ +#define linker_addr(load_address) = \ + ({ = \ + unsigned long __load_address =3D (unsigned long)(load_address); = \ + if ( load_addr_start <=3D __load_address && = \ + __load_address < load_addr_end ) = \ + { = \ + __load_address =3D = \ + __load_address - load_addr_start + linker_addr_start; = \ + } = \ + __load_address; = \ + }) + +static void __attribute__((section(".entry"))) +_setup_initial_pagetables(pte_t *second, pte_t *first, pte_t *zeroeth, + unsigned long map_start, + unsigned long map_end, + unsigned long pa_start, + bool writable) +{ + unsigned long page_addr; + unsigned long index2; + unsigned long index1; + unsigned long index0; + + /* align start addresses */ + map_start &=3D ZEROETH_MAP_MASK; + pa_start &=3D ZEROETH_MAP_MASK; + + page_addr =3D map_start; + while ( page_addr < map_end ) + { + index2 =3D pagetable_second_index(page_addr); + index1 =3D pagetable_first_index(page_addr); + index0 =3D pagetable_zeroeth_index(page_addr); + + /* Setup level2 table */ + second[index2] =3D paddr_to_pte((unsigned long)first); + second[index2].pte |=3D PTE_TABLE; + + /* Setup level1 table */ + first[index1] =3D paddr_to_pte((unsigned long)zeroeth); + first[index1].pte |=3D PTE_TABLE; + + /* Setup level0 table */ + if ( !pte_is_valid(&zeroeth[index0]) ) + { + /* Update level0 table */ + zeroeth[index0] =3D paddr_to_pte((page_addr - map_start) + pa_= start); + zeroeth[index0].pte |=3D PTE_LEAF_DEFAULT; + zeroeth[index0].pte &=3D ~((!writable) ? PTE_WRITABLE : 0); + } + + /* Point to next page */ + page_addr +=3D ZEROETH_SIZE; + } +} + +/* + * setup_initial_pagetables: + * + * 1) Build the page tables for Xen that map the following: + * 1.1) The physical location of Xen (where the bootloader loaded it) + * 1.2) The link-time location of Xen (where the linker expected Xen's + * addresses to be) + * 2) Load the page table into the SATP and enable the MMU + */ +void __attribute__((section(".entry"))) +setup_initial_pagetables(unsigned long load_addr_start, + unsigned long load_addr_end, + unsigned long linker_addr_start, + unsigned long linker_addr_end) +{ + pte_t *second; + pte_t *first; + pte_t *zeroeth; + + clear_pagetables(load_addr_start, load_addr_end, + linker_addr_start, linker_addr_end); + + /* Get the addresses where the page tables were loaded */ + second =3D (pte_t *)load_addr(&xen_second_pagetable); + first =3D (pte_t *)load_addr(&xen_first_pagetable); + zeroeth =3D (pte_t *)load_addr(&xen_zeroeth_pagetable); + + /* + * Create a mapping from Xen's link-time addresses to where they were = actually loaded. + */ + _setup_initial_pagetables(second, first, zeroeth, + linker_addr(&_stext), + linker_addr(&_etext), + load_addr(&_stext), + false); + _setup_initial_pagetables(second, first, zeroeth, + linker_addr(&__init_begin), + linker_addr(&__init_end), + load_addr(&__init_begin), + true); + _setup_initial_pagetables(second, first, zeroeth, + linker_addr(&_srodata), + linker_addr(&_erodata), + load_addr(&_srodata), + false); + _setup_initial_pagetables(second, first, zeroeth, + linker_addr_start, + linker_addr_end, + load_addr_start, + true); + + /* + * Create a mapping of the load time address range to... the load time= address range. + * This mapping is used at boot time only. + */ + _setup_initial_pagetables(second, first, zeroeth, + load_addr_start, + load_addr_end, + load_addr_start, + true); + + /* Ensure page table writes precede loading the SATP */ + asm volatile("sfence.vma"); + + /* Enable the MMU and load the new pagetable for Xen */ + csr_write(CSR_SATP, + (load_addr(xen_second_pagetable) >> PAGE_SHIFT) | SATP_MODE_= SV39 << SATP_MODE_SHIFT); + + phys_offset =3D load_addr_start - linker_addr_start; + + return; +} --=20 2.39.0 From nobody Thu May 16 18:34:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677251224; cv=none; d=zohomail.com; s=zohoarc; b=CkUBgQDiFaG6oxMsB9WWxzIEFvQVFN9tmrFGCi60b4hzw0kpxvTqFwbKWCLuX51AcyJRUuIvXvRCQqZAwLzRuI9j3pd5ry9Jh5gzwOl+/fr1fmsQ1jafjnyv+NaAEu6aliEv7RHat4Fg2wzrJIEqHfGgX1FnwRdfIui5Y7wpSoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677251224; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X/gSRFTkaEkbR97ZxT3k+xBfRgzno3qG9xfy82tbgR4=; b=QFppXgH5wgtcwEMyVgPN6I50KrrCyRIYFjKd+skR7OkKAk/6ahiCWOIEzZtswDmZfm5K7MhmOICfp1ceuKc46m/0qHblgepHEwKMNb/LprN6fGMdnnXy2oQ02rGMGykreGQIm9afkmhNDGtu/t+t9pEglff0jbC6nx0XgiwUZlw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677251223994382.50000120250206; Fri, 24 Feb 2023 07:07:03 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.501139.772765 (Exim 4.92) (envelope-from ) id 1pVZem-0006uc-RN; Fri, 24 Feb 2023 15:06:44 +0000 Received: by outflank-mailman (output) from mailman id 501139.772765; Fri, 24 Feb 2023 15:06:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pVZem-0006uP-OZ; Fri, 24 Feb 2023 15:06:44 +0000 Received: by outflank-mailman (input) for mailman id 501139; Fri, 24 Feb 2023 15:06:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pVZel-0006Ou-Ew for xen-devel@lists.xenproject.org; Fri, 24 Feb 2023 15:06:43 +0000 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [2a00:1450:4864:20::12a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d91818c7-b454-11ed-88bb-e56d68cac8db; Fri, 24 Feb 2023 16:06:43 +0100 (CET) Received: by mail-lf1-x12a.google.com with SMTP id k14so17292528lfj.7 for ; Fri, 24 Feb 2023 07:06:43 -0800 (PST) Received: from 34-6F-24-FC-D2-65.. (46.204.108.92.nat.umts.dynamic.t-mobile.pl. [46.204.108.92]) by smtp.gmail.com with ESMTPSA id d23-20020ac25457000000b004d863fa8681sm1492443lfn.173.2023.02.24.07.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 07:06:42 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d91818c7-b454-11ed-88bb-e56d68cac8db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X/gSRFTkaEkbR97ZxT3k+xBfRgzno3qG9xfy82tbgR4=; b=KpaLs9XDqIEFJGBISyk8iVLbk6s7isw+z2/FCAbm6+7xC6SY7A0ewqbumbWNCnrMvQ JvoYHnJPaW24kXfuzDH1Bf5hTs7vltWdDTSNGyk4Zu95zdXgZABR4i35RRK6rtRrpo0Z YwN0jQ6/cuWW8gL1gifIpgFs7ARDBFaISO7ndeSJC46aYexrRwhlt0LHHikRMoDzCusi ElJwvIkyD2ub4iEtAzRa1ttQttyYojZm+oz1kwydk1kuM3CALwpPEkex4KlbdHVaSWuH 56JDKXoJKHHwscrKrZwptmos84T2OMkUhyLxAUgm9shR12+SzJ8d41/yDxrlluoexxkm iaaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X/gSRFTkaEkbR97ZxT3k+xBfRgzno3qG9xfy82tbgR4=; b=x5IkIonnvJNKuVdWyr/Tge7mu0Re9OuPGo8cw91jut2n1tF+aCfvTW3mmYRdeUAzOM iRxKS+V5zPuShQwkvekuikQB5FIoaPOPwbwoq57vkr8f4Vvp/kGoar/wqIO+7eTLuiwB lg+oDi0XwW54h+CFcIDmiLnEbronSQAhy/Yb/R5iMiIzB1ro0WXrKlcPvZqbR1VzcSYi k4Lt21y6Pqb/Nrebn7dU+xIdbuFjXTsjuNAvWPpph38SnDBimJlVesPapT434a5ilPyZ pFhsFX9G2BuJ1wp4m2rkGQVqxHpLZPQM4VEwzQIjzJ3NbrABDNVVI7TEgGnH7NiPikbz hGHw== X-Gm-Message-State: AO0yUKWo1nCl8eaxba9dXtLt6OizDV0xHkxenwPhF4xrUrK1ecnyjVpi tfQi1TXoGzllsBfEGxKAHVlT+XjLbFc= X-Google-Smtp-Source: AK7set9qr9ZwCV993coDibwSZiYqqCn2yTQnL7BMb3eCLn+q32l0dNLfCPvrA7NMVssXL087GeITSg== X-Received: by 2002:a19:700d:0:b0:4dc:554b:d27e with SMTP id h13-20020a19700d000000b004dc554bd27emr5013319lfc.65.1677251202580; Fri, 24 Feb 2023 07:06:42 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v1 2/3] xen/riscv: setup initial pagetables Date: Fri, 24 Feb 2023 17:06:34 +0200 Message-Id: <83444f8f90cf2adf431762d919ba958a25ff8ce4.1677250203.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677251226215100005 Content-Type: text/plain; charset="utf-8" Calculate load and linker linker image addresses and setup initial pagetables. Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/setup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index b7cd438a1d..f69bc278bb 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -1,9 +1,11 @@ #include #include #include +#include =20 #include #include +#include #include =20 /* Xen stack for bringing up the first CPU. */ @@ -43,6 +45,11 @@ static void __init disable_fpu(void) =20 void __init noreturn start_xen(void) { + unsigned long load_start =3D (unsigned long)start; + unsigned long load_end =3D load_start + (unsigned long)(_end - _s= tart); + unsigned long linker_start =3D (unsigned long)_start; + unsigned long linker_end =3D (unsigned long)_end; + /* * The following things are passed by bootloader: * a0 -> hart_id @@ -65,6 +72,10 @@ void __init noreturn start_xen(void) =20 test_macros_from_bug_h(); =20 + setup_initial_pagetables(load_start, load_end, linker_start, linker_en= d); + + early_printk("MMU has been enabled\n"); + for ( ;; ) asm volatile ("wfi"); =20 --=20 2.39.0 From nobody Thu May 16 18:34:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677251222; cv=none; d=zohomail.com; s=zohoarc; b=giSdivZjcXG8E0xct/JRfwh48gPOu0uJnUmtLVikqg0qAE64fdXp/0x3Wol5KHpBiiVbwtypO5HdeDTjfOM/fo5IG4bu8m4skxkwyu+flNlXGm2ht6+la8HPxp+/INPomFez7xHHipQGAXqBZY/dyMcBtMt1C/fsIipw4OZjIhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677251222; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AWdB+WhVKhbKIc4Ieg60li/sx7jyPhuZ3hOGCvSZofI=; b=jd8Fsp+3itp6XHqdjJTGKJguhaZyDsrZf0qa13QS0au1yRVAa8VVtapjTMRi0Sc0RxfEvHCIP6/u+ogpbAa03xvo+nfVJfWPh+9VgK1SdWrsoBsSnWInyimCvdmxu6YlDKSLP5pGT9KDbjTMxbOXP9EvsI4joEoUDkwbaWDxTSY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677251222927211.12970644592144; Fri, 24 Feb 2023 07:07:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.501140.772776 (Exim 4.92) (envelope-from ) id 1pVZeo-0007BP-4l; Fri, 24 Feb 2023 15:06:46 +0000 Received: by outflank-mailman (output) from mailman id 501140.772776; Fri, 24 Feb 2023 15:06:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pVZeo-0007BI-1j; Fri, 24 Feb 2023 15:06:46 +0000 Received: by outflank-mailman (input) for mailman id 501140; Fri, 24 Feb 2023 15:06:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pVZem-0006Ou-Ll for xen-devel@lists.xenproject.org; Fri, 24 Feb 2023 15:06:44 +0000 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [2a00:1450:4864:20::22e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d9c83172-b454-11ed-88bb-e56d68cac8db; Fri, 24 Feb 2023 16:06:44 +0100 (CET) Received: by mail-lj1-x22e.google.com with SMTP id y14so7341641ljq.4 for ; Fri, 24 Feb 2023 07:06:44 -0800 (PST) Received: from 34-6F-24-FC-D2-65.. (46.204.108.92.nat.umts.dynamic.t-mobile.pl. [46.204.108.92]) by smtp.gmail.com with ESMTPSA id d23-20020ac25457000000b004d863fa8681sm1492443lfn.173.2023.02.24.07.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 07:06:43 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d9c83172-b454-11ed-88bb-e56d68cac8db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AWdB+WhVKhbKIc4Ieg60li/sx7jyPhuZ3hOGCvSZofI=; b=i3735LWE9VNOsxiDAfi7bdl1+CjDSmrUFuH9jCeC/+mmv5RwMtAr3zp6GiElGraKmr C8d8D31tKEujTdEC2XU5xthFrqRktVGEQMw7hMBkk38hsjdzxuyTVlW7+prsoqLAmAdw 0DbOdlkGvYQgZEWJH7nMwRXm8ZrE5BFvAXAbQ1tZGWzDSNisS1T5NwJbcdRplWGpjBuA +9S30q5f2VhqjsWf8zVZt8HZB0OtNE7mJMq79nEs67GvfOS5anmI17B0Z88OtcqHA5Vl ZXxy+jYRc2FfnrQRiGQPwtkBXUcCDpCCmN9qI4bQU2vny/LaBA2uHZjSLMpBXD+LHHDE YjdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AWdB+WhVKhbKIc4Ieg60li/sx7jyPhuZ3hOGCvSZofI=; b=d/gcpQcuuzmk86aMBd/ssJYLgxIx2h6kcUYywCDfLwYMsZA26qc3EFkpOwz0VkVbr6 f/f/QZEUoxmMir8HkiiFhPj6GKmxdTBGE/DdLVxQIBpdmHaHR3lAM5qoUjPEK5SzTBRC XsWBK8vwbPKu36nQpWIhuVXqK0w9NEMMgNzWkjL4pnldB9Co7JxppQU63+bpn3f7HKhd mSIUi3GQd1pSqjtf/ob6KqrHAibd8w/gyTJ6IcIixI88w7bKgYVoYF1kMyQUUwU2yw6P AhIZmwBokDGMgNq9ycyx3o1j5+Gq/kELG3mu/95OFMXJ2EwMPgJeiA95w6U6hmBWqHaj mFQw== X-Gm-Message-State: AO0yUKXHI+dQHkoq9CGeyGaO15JqS0twPRG0pM8eJaiJpp+Ybo0qURCi j6i8Jo+aIQFXX7PYL0usgQyQ/I7kSMI= X-Google-Smtp-Source: AK7set8iTORSXQRVgsqy08wdFvBsYysGaVjpQnbN6EJsnRPi7bOszKhjVPpe7vkNSMR1CAiv7PFbag== X-Received: by 2002:a2e:a4a1:0:b0:294:694f:54 with SMTP id g1-20020a2ea4a1000000b00294694f0054mr5981834ljm.0.1677251203837; Fri, 24 Feb 2023 07:06:43 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Doug Goldstein Subject: [PATCH v1 3/3] automation: update RISC-V smoke test Date: Fri, 24 Feb 2023 17:06:35 +0200 Message-Id: <38ddf88eabd9cc36c332d6a27c6ee1242d33df19.1677250203.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677251224241100001 Content-Type: text/plain; charset="utf-8" The smoke test was updated to verify that MMU has been enabled. Signed-off-by: Oleksii Kurochko --- automation/scripts/qemu-smoke-riscv64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/scripts/qemu-smoke-riscv64.sh b/automation/scripts/= qemu-smoke-riscv64.sh index 02fc66be03..01cd08e407 100755 --- a/automation/scripts/qemu-smoke-riscv64.sh +++ b/automation/scripts/qemu-smoke-riscv64.sh @@ -16,5 +16,5 @@ qemu-system-riscv64 \ |& tee smoke.serial =20 set -e -(grep -q "WARN is most likely working" smoke.serial) || exit 1 +(grep -q "MMU has been enabled" smoke.serial) || exit 1 exit 0 --=20 2.39.0