From nobody Fri May 17 09:18:35 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=1680882551; cv=none; d=zohomail.com; s=zohoarc; b=hOrmcTIDslaSXhos8m0lwM45yMmBhpvnb1LY5tlBwXxPOj51q5Lw/xYHqYaim/fHI28VabEuh2wi/fswYu+y4mgB7nfNKAKm+c9wrOzSrOBaVsgrRONbuPqZEf2CYsUYRTQhKc1QNT1M7Xo8Xfgh4ooi5VYZcDPVek8KlzfKyos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680882551; 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=LmPb2JvpArMyMhsNogOHkOdzUdZrOYWvyQ6G5yv0Ex4=; b=j3MwIs97dezPlegJvC4PJ5uzDndzLPXQYMW8XtzNljPH1ux5GWfEs2FLmYcnHp1tbOK3+nUcsRIDXP3YX7WdxSgKz4rADm0U7QMHZpEnztM3zy7ndcI9DLS8MHEcNnpR/Z3eAku1nDhtJXNeo12VKb4WqCajdVBjUkyLtN8Jzgc= 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 1680882551459991.2554146045866; Fri, 7 Apr 2023 08:49:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519068.806242 (Exim 4.92) (envelope-from ) id 1pkoKX-0002Mg-7D; Fri, 07 Apr 2023 15:48:49 +0000 Received: by outflank-mailman (output) from mailman id 519068.806242; Fri, 07 Apr 2023 15:48:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pkoKX-0002Ls-1z; Fri, 07 Apr 2023 15:48:49 +0000 Received: by outflank-mailman (input) for mailman id 519068; Fri, 07 Apr 2023 15:48:47 +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 1pkoKV-0001rF-An for xen-devel@lists.xenproject.org; Fri, 07 Apr 2023 15:48:47 +0000 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [2a00:1450:4864:20::231]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ad7100aa-d55b-11ed-85db-49a42c6b2330; Fri, 07 Apr 2023 17:48:45 +0200 (CEST) Received: by mail-lj1-x231.google.com with SMTP id bd22so1726694ljb.5 for ; Fri, 07 Apr 2023 08:48:44 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id v12-20020a2e9f4c000000b00295a583a20bsm874765ljk.74.2023.04.07.08.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 08:48:43 -0700 (PDT) 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: ad7100aa-d55b-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680882524; x=1683474524; 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=LmPb2JvpArMyMhsNogOHkOdzUdZrOYWvyQ6G5yv0Ex4=; b=Du9Fd7xXhKP5Ec9O6tMgoW2N50Btzk+xQq9lW8JFxZ/x2P+PsDdzMMbkUpzhSS6IaK bEyAV6A7SmEqK5FHXZwfNUr2f7x2IS/U0FUkKjth13iJJYU6FsUnapmHi/ApoCvP4SBj viaa/nUeklzEPMaak0qYM+zXZ1wrKaa7wdtQCVnTC9U0RVxit62/nKCdBK5mHAm7VKMU ayhlGXBvxFYnlzB8XAGcaW5tFkKP7ciP6Z8zE/aiPwi6BWs8q6GFxE4+6qzDXQOJXidS nFih+KlCk5GT4WONIeUJeRX/gG1IF6DU0NhIOK84X350KMuuVmO8nGLBX9O0K8qUqG8I X+DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680882524; x=1683474524; 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=LmPb2JvpArMyMhsNogOHkOdzUdZrOYWvyQ6G5yv0Ex4=; b=Ou5wx2qUr9UJZR///L75JIld1txxDsC44atFWMn+F8iG4VSgvYUcLjoWTt6LeSA+9M 283m6VUFlBbPuqP4dmVDVaEf4QOURLfhzX9zDrB4+IgV6wVL78I0mqklJUYbLnfGLr/O 2+fnOpIypFlOIFbXgjq7MJgDfrjGUhRZBf2Nv5YQWwnzhFyQe+rbSsQHd9QYvd6ZRoLI tnyvYKAQ0FSdjINKEcOjnMzDBC6Ukgbf0aGJwMtwJ841p4a4TkAtUuaDVkH4VF6QWntq PFeRQk6joQnOMa1BlC4iJjfZO1lyoxsa7n6OcGMxVHhfSPe9lchaLr3XF4riV/gsSZt/ dnHQ== X-Gm-Message-State: AAQBX9c6NYaQnPdvUd532BUU+Qd7VaVCt4QyslKKuAcRafhvDEgV5IkO lWtFY90PRMqaQw/pwS8A+F0hJoQs1eg= X-Google-Smtp-Source: AKy350ZWfsrVbxSNagZoTRjLwxe5AJ9ycaTov9PXA5oVeOpvcWSZ3SsT7pnbDsGhGlaKl/LEna51nw== X-Received: by 2002:a2e:9698:0:b0:298:b045:af96 with SMTP id q24-20020a2e9698000000b00298b045af96mr695028lji.9.1680882523577; Fri, 07 Apr 2023 08:48:43 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v4 1/3] xen/riscv: introduce setup_initial_pages Date: Fri, 7 Apr 2023 18:48:37 +0300 Message-Id: <50ed83073ccb440fb651070de8b0abebd3888b43.1680882176.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680882553666100007 Content-Type: text/plain; charset="utf-8" The idea was taken from xvisor but the following changes were done: * Use only a minimal part of the code enough to enable MMU * rename {_}setup_initial_pagetables functions * add an argument for setup_initial_mapping to have an opportunity to make set PTE flags. * update setup_initial_pagetables function to map sections with correct PTE flags. * Rewrite enable_mmu() to C. * map linker addresses range to load addresses range without 1:1 mapping. It will be 1:1 only in case when load_start_addr is equal to linker_start_addr. * add safety checks such as: * Xen size is less than page size * linker addresses range doesn't overlap load addresses range * Rework macros {THIRD,SECOND,FIRST,ZEROETH}_{SHIFT,MASK} * change PTE_LEAF_DEFAULT to RW instead of RWX. * Remove phys_offset as it is not used now * Remove alignment of {map, pa}_start &=3D XEN_PT_LEVEL_MAP_MASK(0); in setup_inital_mapping() as they should be already aligned. Make a check that {map_pa}_start are aligned. * Remove clear_pagetables() as initial pagetables will be zeroed during bss initialization * Remove __attribute__((section(".entry")) for setup_initial_pagetables() as there is no such section in xen.lds.S * Update the argument of pte_is_valid() to "const pte_t *p" * Add check that Xen's load address is aligned at 4k boundary * Refactor setup_initial_pagetables() so it is mapping linker address range to load address range. After setup needed permissions for specific section ( such as .text, .rodata, etc ) otherwise RW permission will be set by default. * Add function to check that requested SATP_MODE is supported Origin: git@github.com:xvisor/xvisor.git 9be2fdd7 Signed-off-by: Oleksii Kurochko --- Changes in V4: * use GB() macros instead of defining SZ_1G * hardcode XEN_VIRT_START and add comment (ADDRESS_SPACE_END + 1 - GB(1)) * remove unnecessary 'asm' word at the end of #error * encapsulate pte_t definition in a struct * rename addr_to_ppn() to ppn_to_paddr(). * change type of paddr argument from const unsigned long to paddr_t * pte_to_paddr() update prototype. * calculate size of Xen binary based on an amount of page tables * use unsgined int instead of 'uint32_t' instead of uint32_t as their use isn't warranted. * remove extern of bss_{start,end} as they aren't used in mm.c anymore * fix code style * add argument for HANDLE_PGTBL macros instead of curr_lvl_num variable * make enable_mmu() as noinline to prevent under link-time optimization because of the nature of enable_mmu() * add function to check that SATP_MODE is supported. * update the commit message * update setup_initial_pagetables to set correct PTE flags in one pass instead of calling setup_pte_permissions after setup_initial_pagetables= () as setup_initial_pagetables() isn't used to change permission flags. --- Changes in V3: - update definition of pte_t structure to have a proper size of pte_t in case of RV32. - update asm/mm.h with new functions and remove unnecessary 'extern'. - remove LEVEL_* macros as only XEN_PT_LEVEL_* are enough. - update paddr_to_pte() to receive permissions as an argument. - add check that map_start & pa_start is properly aligned. - move defines PAGETABLE_ORDER, PAGETABLE_ENTRIES, PTE_PPN_SHIFT to - Rename PTE_SHIFT to PTE_PPN_SHIFT - refactor setup_initial_pagetables: map all LINK addresses to LOAD addres= ses and after setup PTEs permission for sections; update check that linker and load addresses don't overlap. - refactor setup_initial_mapping: allocate pagetable 'dynamically' if it is necessary. - rewrite enable_mmu in C; add the check that map_start and pa_start are aligned on 4k boundary. - update the comment for setup_initial_pagetable funcion - Add RV_STAGE1_MODE to support different MMU modes - set XEN_VIRT_START very high to not overlap with load address range - align bss section --- Changes in V2: * update the commit message: * Remove {ZEROETH,FIRST,...}_{SHIFT,MASK, SIZE,...} and introduce instead of them XEN_PT_LEVEL_*() and LEVEL_* * Rework pt_linear_offset() and pt_index based on XEN_PT_LEVEL_*() * Remove clear_pagetables() functions as pagetables were zeroed during .bss initialization * Rename _setup_initial_pagetables() to setup_initial_mapping() * Make PTE_DEFAULT equal to RX. * Update prototype of setup_initial_mapping(..., bool writable) ->=20 setup_initial_mapping(..., UL flags) =20 * Update calls of setup_initial_mapping according to new prototype * Remove unnecessary call of: _setup_initial_pagetables(..., load_addr_start, load_addr_end, load_addr= _start, ...) * Define index* in the loop of setup_initial_mapping * Remove attribute "__attribute__((section(".entry")))" for setup_initial_= pagetables() as we don't have such section * make arguments of paddr_to_pte() and pte_is_valid() as const. * make xen_second_pagetable static. * use instead of declaring extern unsigned long _stext, 0et= ext, _srodata, _erodata * update 'extern unsigned long __init_begin' to 'extern unsigned long __i= nit_begin[]' * use aligned() instead of "__attribute__((__aligned__(PAGE_SIZE)))" * set __section(".bss.page_aligned") for page tables arrays * fix identatations * Change '__attribute__((section(".entry")))' to '__init' * Remove phys_offset as it isn't used now. * Remove alignment of {map, pa}_start &=3D XEN_PT_LEVEL_MAP_MASK(0); in setup_inital_mapping() as they should be already aligned. * Remove clear_pagetables() as initial pagetables will be zeroed during bss initialization * Remove __attribute__((section(".entry")) for setup_initial_pagetables() as there is no such section in xen.lds.S * Update the argument of pte_is_valid() to "const pte_t *p" --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/include/asm/config.h | 12 +- xen/arch/riscv/include/asm/mm.h | 9 + xen/arch/riscv/include/asm/page-bits.h | 10 + xen/arch/riscv/include/asm/page.h | 65 +++++ xen/arch/riscv/mm.c | 319 +++++++++++++++++++++++++ xen/arch/riscv/riscv64/head.S | 2 + xen/arch/riscv/setup.c | 11 + xen/arch/riscv/xen.lds.S | 4 + 9 files changed, 432 insertions(+), 1 deletion(-) 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/config.h b/xen/arch/riscv/include/a= sm/config.h index 763a922a04..0cf9673558 100644 --- a/xen/arch/riscv/include/asm/config.h +++ b/xen/arch/riscv/include/asm/config.h @@ -39,12 +39,22 @@ name: #endif =20 -#define XEN_VIRT_START _AT(UL, 0x80200000) +#ifdef CONFIG_RISCV_64 +#define XEN_VIRT_START 0xFFFFFFFFC0000000 /* (_AC(-1, UL) + 1 - GB(1)) */ +#else +#error "RV32 isn't supported" +#endif =20 #define SMP_CACHE_BYTES (1 << 6) =20 #define STACK_SIZE PAGE_SIZE =20 +#ifdef CONFIG_RISCV_64 +#define RV_STAGE1_MODE SATP_MODE_SV39 +#else +#define RV_STAGE1_MODE SATP_MODE_SV32 +#endif + #endif /* __RISCV_CONFIG_H__ */ /* * Local variables: 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..e16ce66fae --- /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(void); + +void enable_mmu(void); +void cont_after_mmu_is_enabled(void); + +#endif /* _ASM_RISCV_MM_H */ diff --git a/xen/arch/riscv/include/asm/page-bits.h b/xen/arch/riscv/includ= e/asm/page-bits.h index 1801820294..0879a527f2 100644 --- a/xen/arch/riscv/include/asm/page-bits.h +++ b/xen/arch/riscv/include/asm/page-bits.h @@ -1,6 +1,16 @@ #ifndef __RISCV_PAGE_BITS_H__ #define __RISCV_PAGE_BITS_H__ =20 +#ifdef CONFIG_RISCV_64 +#define PAGETABLE_ORDER (9) +#else /* CONFIG_RISCV_32 */ +#define PAGETABLE_ORDER (10) +#endif + +#define PAGETABLE_ENTRIES (1 << PAGETABLE_ORDER) + +#define PTE_PPN_SHIFT 10 + #define PAGE_SHIFT 12 /* 4 KiB Pages */ #define PADDR_BITS 56 /* 44-bit PPN */ =20 diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm= /page.h new file mode 100644 index 0000000000..30406aa614 --- /dev/null +++ b/xen/arch/riscv/include/asm/page.h @@ -0,0 +1,65 @@ +#ifndef _ASM_RISCV_PAGE_H +#define _ASM_RISCV_PAGE_H + +#include +#include + +#define VPN_MASK ((unsigned long)(PAGETABLE_ENTRIES - 1= )) + +#define XEN_PT_LEVEL_ORDER(lvl) ((lvl) * PAGETABLE_ORDER) +#define XEN_PT_LEVEL_SHIFT(lvl) (XEN_PT_LEVEL_ORDER(lvl) + PAGE_SHIFT) +#define XEN_PT_LEVEL_SIZE(lvl) (_AT(paddr_t, 1) << XEN_PT_LEVEL_SHIFT= (lvl)) +#define XEN_PT_LEVEL_MAP_MASK(lvl) (~(XEN_PT_LEVEL_SIZE(lvl) - 1)) +#define XEN_PT_LEVEL_MASK(lvl) (VPN_MASK << XEN_PT_LEVEL_SHIFT(lvl)) + +#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_WRITAB= LE) +#define PTE_TABLE (PTE_VALID) + +/* Calculate the offsets into the pagetables for a given VA */ +#define pt_linear_offset(lvl, va) ((va) >> XEN_PT_LEVEL_SHIFT(lvl)) + +#define pt_index(lvl, va) pt_linear_offset(lvl, (va) & XEN_PT_LEVEL_MASK(l= vl)) + +/* Page Table entry */ +typedef struct { +#ifdef CONFIG_RISCV_64 +uint64_t pte; +#else +uint32_t pte; +#endif +} pte_t; + +#define addr_to_pte(x) (((x) >> PTE_PPN_SHIFT) << PAGE_SHIFT) + +/* 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 ppn_to_paddr(x) (((x) >> PAGE_SHIFT) << PTE_PPN_SHIFT) + +static inline pte_t paddr_to_pte(const paddr_t paddr, + const unsigned long permissions) +{ + unsigned long tmp =3D ppn_to_paddr(paddr); + return (pte_t) { .pte =3D tmp | permissions }; +} + +static inline paddr_t pte_to_paddr(const pte_t pte) +{ + return addr_to_pte(pte.pte); +} + +static inline bool pte_is_valid(const 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..43b7181c33 --- /dev/null +++ b/xen/arch/riscv/mm.c @@ -0,0 +1,319 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +struct mmu_desc { + unsigned long num_levels; + unsigned int pgtbl_count; + pte_t *next_pgtbl; + pte_t *pgtbl_base; +}; + +extern unsigned char cpu0_boot_stack[STACK_SIZE]; + +#define PHYS_OFFSET ((unsigned long)_start - XEN_VIRT_START) +#define LOAD_TO_LINK(addr) ((addr) - PHYS_OFFSET) +#define LINK_TO_LOAD(addr) ((addr) + PHYS_OFFSET) + + +/* + * It is expected that Xen won't be more then 2 MB. + * The check in xen.lds.S guarantees that. + * At least 4 page (in case when Sv48 or Sv57 are used ) + * tables are needed to cover 2 MB. One for each page level + * table with PAGE_SIZE =3D 4 Kb + * + * One L0 page table can cover 2 MB + * (512 entries of one page table * PAGE_SIZE). + * + * It might be needed one more page table in case when + * Xen load address isn't 2 MB aligned. + * + */ +#define PGTBL_INITIAL_COUNT (5) + +#define PGTBL_ENTRY_AMOUNT (PAGE_SIZE / sizeof(pte_t)) + +pte_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) +stage1_pgtbl_root[PGTBL_ENTRY_AMOUNT]; + +pte_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) +stage1_pgtbl_nonroot[PGTBL_INITIAL_COUNT * PGTBL_ENTRY_AMOUNT]; + +#define HANDLE_PGTBL(curr_lvl_num) = \ + index =3D pt_index(curr_lvl_num, page_addr); = \ + if ( pte_is_valid(pgtbl[index]) ) = \ + { = \ + /* Find L{ 0-3 } table */ = \ + pgtbl =3D (pte_t *)pte_to_paddr(pgtbl[index]); = \ + } = \ + else = \ + { = \ + /* Allocate new L{0-3} page table */ = \ + if ( mmu_desc->pgtbl_count =3D=3D PGTBL_INITIAL_COUNT ) = \ + { = \ + early_printk("(XEN) No initial table available\n"); = \ + /* panic(), BUG() or ASSERT() aren't ready now. */ = \ + die(); = \ + } = \ + mmu_desc->pgtbl_count++; = \ + pgtbl[index] =3D paddr_to_pte((unsigned long)mmu_desc->next_pgtbl,= \ + PTE_VALID); = \ + pgtbl =3D mmu_desc->next_pgtbl; = \ + mmu_desc->next_pgtbl +=3D PGTBL_ENTRY_AMOUNT; = \ + } + +static void __init setup_initial_mapping(struct mmu_desc *mmu_desc, + unsigned long map_start, + unsigned long map_end, + unsigned long pa_start, + unsigned long permissions) +{ + unsigned int index; + pte_t *pgtbl; + unsigned long page_addr; + pte_t pte_to_be_written; + unsigned long paddr; + unsigned long tmp_permissions; + + if ( (unsigned long)_start % XEN_PT_LEVEL_SIZE(0) ) + { + early_printk("(XEN) Xen should be loaded at 4k boundary\n"); + die(); + } + + if ( map_start & ~XEN_PT_LEVEL_MAP_MASK(0) || + pa_start & ~XEN_PT_LEVEL_MAP_MASK(0) ) + { + early_printk("(XEN) map and pa start addresses should be aligned\n= "); + /* panic(), BUG() or ASSERT() aren't ready now. */ + die(); + } + + page_addr =3D map_start; + while ( page_addr < map_end ) + { + pgtbl =3D mmu_desc->pgtbl_base; + + switch (mmu_desc->num_levels) + { + case 4: /* Level 3 */ + HANDLE_PGTBL(3); + case 3: /* Level 2 */ + HANDLE_PGTBL(2); + case 2: /* Level 1 */ + HANDLE_PGTBL(1); + case 1: /* Level 0 */ + index =3D pt_index(0, page_addr); + paddr =3D (page_addr - map_start) + pa_start; + + tmp_permissions =3D permissions; + + if ( is_kernel_text(LINK_TO_LOAD(page_addr)) || + is_kernel_inittext(LINK_TO_LOAD(page_addr)) ) + tmp_permissions =3D + PTE_EXECUTABLE | PTE_READABLE | PTE_VALID; + + if ( is_kernel_rodata(LINK_TO_LOAD(page_addr)) ) + tmp_permissions =3D PTE_READABLE | PTE_VALID; + + pte_to_be_written =3D paddr_to_pte(paddr, tmp_permissions); + + if ( !pte_is_valid(pgtbl[index]) ) + pgtbl[index] =3D pte_to_be_written; + else + { + /* + * get an adresses of current pte and that one to + * be written without permission flags + */ + unsigned long curr_pte =3D + pgtbl[index].pte & ~((1 << PTE_PPN_SHIFT) - 1); + + pte_to_be_written.pte &=3D ~((1 << PTE_PPN_SHIFT) - 1); + + if ( curr_pte !=3D pte_to_be_written.pte ) + { + early_printk("PTE that is intended to write isn't = the" + "same that the once are overwriting\n"= ); + /* panic(), aren't ready now. */ + die(); + } + } + } + + /* Point to next page */ + page_addr +=3D XEN_PT_LEVEL_SIZE(0); + } +} + +static void __init calc_pgtbl_lvls_num(struct mmu_desc *mmu_desc) +{ + unsigned long satp_mode =3D RV_STAGE1_MODE; + + /* Number of page table levels */ + switch (satp_mode) + { + case SATP_MODE_SV32: + mmu_desc->num_levels =3D 2; + break; + case SATP_MODE_SV39: + mmu_desc->num_levels =3D 3; + break; + case SATP_MODE_SV48: + mmu_desc->num_levels =3D 4; + break; + default: + early_printk("(XEN) Unsupported SATP_MODE\n"); + die(); + } +} + +static bool __init check_pgtbl_mode_support(struct mmu_desc *mmu_desc, + unsigned long load_start, + unsigned long satp_mode) +{ + bool is_mode_supported =3D false; + unsigned int index; + unsigned int page_table_level =3D (mmu_desc->num_levels - 1); + unsigned level_map_mask =3D XEN_PT_LEVEL_MAP_MASK(page_table_level); + + unsigned long aligned_load_start =3D load_start & level_map_mask; + unsigned long aligned_page_size =3D XEN_PT_LEVEL_SIZE(page_table_level= ); + unsigned long xen_size =3D (unsigned long)(_end - start); + + if ( (load_start + xen_size) > (aligned_load_start + aligned_page_size= ) ) + { + early_printk("please place Xen to be in range of PAGE_SIZE " + "where PAGE_SIZE is XEN_PT_LEVEL_SIZE( {L3 | L2 | L1}= ) " + "depending on expected SATP_MODE \n" + "XEN_PT_LEVEL_SIZE is defined in \n"); + die(); + } + + index =3D pt_index(page_table_level, aligned_load_start); + stage1_pgtbl_root[index] =3D paddr_to_pte(aligned_load_start, + PTE_LEAF_DEFAULT | PTE_EXECUTA= BLE); + + asm volatile("sfence.vma"); + csr_write(CSR_SATP, + ((unsigned long)stage1_pgtbl_root >> PAGE_SHIFT) | + satp_mode << SATP_MODE_SHIFT); + + if ( (csr_read(CSR_SATP) >> SATP_MODE_SHIFT) =3D=3D satp_mode ) + is_mode_supported =3D true; + + /* Clean MMU root page table and disable MMU */ + stage1_pgtbl_root[index] =3D paddr_to_pte(0x0, 0x0); + + csr_write(CSR_SATP, 0); + asm volatile("sfence.vma"); + + return is_mode_supported; +} + +/* + * setup_initial_pagetables: + * + * Build the page tables for Xen that map the following: + * 1. Calculate page table's level numbers. + * 2. Init mmu description structure. + * 3. Check that linker addresses range doesn't overlap + * with load addresses range + * 4. Map all linker addresses and load addresses ( it shouldn't + * be 1:1 mapped and will be 1:1 mapped only in case if + * linker address is equal to load address ) with + * RW permissions by default. + * 5. Setup proper PTE permissions for each section. + */ +void __init setup_initial_pagetables(void) +{ + struct mmu_desc mmu_desc =3D { 0, 0, NULL, 0 }; + + /* + * Access to _{stard, end } is always PC-relative + * thereby when access them we will get load adresses + * of start and end of Xen + * To get linker addresses LOAD_TO_LINK() is required + * to use + */ + unsigned long load_start =3D (unsigned long)_start; + unsigned long load_end =3D (unsigned long)_end; + unsigned long linker_start =3D LOAD_TO_LINK(load_start); + unsigned long linker_end =3D LOAD_TO_LINK(load_end); + + if ( (linker_start !=3D load_start) && + (linker_start <=3D load_end) && (load_start <=3D linker_end) ) { + early_printk("(XEN) linker and load address ranges overlap\n"); + die(); + } + + calc_pgtbl_lvls_num(&mmu_desc); + + if ( !check_pgtbl_mode_support(&mmu_desc, load_start, RV_STAGE1_MODE) ) + { + early_printk("requested MMU mode isn't supported by CPU\n" + "Please choose different in \n"); + die(); + } + + mmu_desc.pgtbl_base =3D stage1_pgtbl_root; + mmu_desc.next_pgtbl =3D stage1_pgtbl_nonroot; + + setup_initial_mapping(&mmu_desc, + linker_start, + linker_end, + load_start, + PTE_LEAF_DEFAULT); +} + +void __init noinline enable_mmu() +{ + /* + * Calculate a linker time address of the mmu_is_enabled + * label and update CSR_STVEC with it. + * MMU is configured in a way where linker addresses are mapped + * on load addresses so in a case when linker addresses are not equal + * to load addresses, after MMU is enabled, it will cause + * an exception and jump to linker time addresses. + * Otherwise if load addresses are equal to linker addresses the code + * after mmu_is_enabled label will be executed without exception. + */ + csr_write(CSR_STVEC, LOAD_TO_LINK((unsigned long)&&mmu_is_enabled)); + + /* 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, + ((unsigned long)stage1_pgtbl_root >> PAGE_SHIFT) | + RV_STAGE1_MODE << SATP_MODE_SHIFT); + + asm volatile(".align 2"); + mmu_is_enabled: + /* + * Stack should be re-inited as: + * 1. Right now an address of the stack is relative to load time + * addresses what will cause an issue in case of load start address + * isn't equal to linker start address. + * 2. Addresses in stack are all load time relative which can be an + * issue in case when load start address isn't equal to linker + * start address. + */ + asm volatile ("mv sp, %0" : : "r"((unsigned long)cpu0_boot_stack + STA= CK_SIZE)); + + /* + * We can't return to the caller because the stack was reseted + * and it may have stash some variable on the stack. + * Jump to a brand new function as the stack was reseted + */ + cont_after_mmu_is_enabled(); +} + diff --git a/xen/arch/riscv/riscv64/head.S b/xen/arch/riscv/riscv64/head.S index 8887f0cbd4..b3309d902c 100644 --- a/xen/arch/riscv/riscv64/head.S +++ b/xen/arch/riscv/riscv64/head.S @@ -1,4 +1,5 @@ #include +#include #include =20 .section .text.header, "ax", %progbits @@ -32,3 +33,4 @@ ENTRY(start) add sp, sp, t0 =20 tail start_xen + diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 3786f337e0..315804aa87 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -2,6 +2,7 @@ #include =20 #include +#include =20 /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] @@ -26,3 +27,13 @@ void __init noreturn start_xen(unsigned long bootcpu_id, =20 unreachable(); } + +void __init noreturn cont_after_mmu_is_enabled(void) +{ + early_printk("All set up\n"); + + for ( ;; ) + asm volatile ("wfi"); + + unreachable(); +} diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S index f299ea8422..e00b5c803a 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -136,6 +136,7 @@ SECTIONS . =3D ALIGN(POINTER_ALIGN); __init_end =3D .; =20 + . =3D ALIGN(PAGE_SIZE); .bss : { /* BSS */ __bss_start =3D .; *(.bss.stack_aligned) @@ -169,3 +170,6 @@ SECTIONS =20 ASSERT(!SIZEOF(.got), ".got non-empty") ASSERT(!SIZEOF(.got.plt), ".got.plt non-empty") + +ASSERT(_end - _start <=3D MB(2), "Xen too large for early-boot assumptions= ") + --=20 2.39.2 From nobody Fri May 17 09:18:35 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=1680882548; cv=none; d=zohomail.com; s=zohoarc; b=Nkm5Bu68Ri7uqDqYJCoo9J7qaLArbU0GYIJ//cAbO7/ded6mGixwsRRaT42QT6kzSGI0ph3/cLLNrJzHJJXtEraY1FPk4vjtk12LSFbpiZYCvTdFXKvvixf5+7SvMHSRK0DHeTB59FJaC+dmyz6Lu2kiShmEMbHStJmYa/B/7bo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680882548; 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=Bvofdso7h4C0wbCuGQpq+8NVtokRUIZ6ky3V3PNneG0=; b=T5evrt6M69Tzsr2eHOUn4YgrOSaFsEa9tFokAupFHPJ5wso5M/3SA6tbN3KwV/8/8vaGgomsQuizWyp5mpXWoNwZOB/z8B6zZzjOOKllCUk2NLq6F3mbO24eJMx6qvcLDXwRcLBnhYxK+gLlrES6eh3ogf16V8oRQkUYe0nXQ4Q= 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 1680882548758699.6534808125484; Fri, 7 Apr 2023 08:49:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519066.806223 (Exim 4.92) (envelope-from ) id 1pkoKV-0001tv-O1; Fri, 07 Apr 2023 15:48:47 +0000 Received: by outflank-mailman (output) from mailman id 519066.806223; Fri, 07 Apr 2023 15:48:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pkoKV-0001tG-JD; Fri, 07 Apr 2023 15:48:47 +0000 Received: by outflank-mailman (input) for mailman id 519066; Fri, 07 Apr 2023 15:48:46 +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 1pkoKU-0001rF-LK for xen-devel@lists.xenproject.org; Fri, 07 Apr 2023 15:48:46 +0000 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [2a00:1450:4864:20::233]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ad953bc0-d55b-11ed-85db-49a42c6b2330; Fri, 07 Apr 2023 17:48:45 +0200 (CEST) Received: by mail-lj1-x233.google.com with SMTP id s20so23593292ljp.7 for ; Fri, 07 Apr 2023 08:48:45 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id v12-20020a2e9f4c000000b00295a583a20bsm874765ljk.74.2023.04.07.08.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 08:48:44 -0700 (PDT) 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: ad953bc0-d55b-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680882524; x=1683474524; 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=Bvofdso7h4C0wbCuGQpq+8NVtokRUIZ6ky3V3PNneG0=; b=UDjqnxv9yR2iTme8IfxrqJoKtTT30hQa3MiTyTzUHwl68nl1Pg/RDJfQve/u477hyf lkcy8haZp0tzhaVuLFKsyA1honQArutrJbWZz954UQQqOpeE7WQ/eO8dJoHJh2OP78oA p43yE+1vK+VNYdcRlgMOimU+ZWNBeUqBTXgbrjzcAVRBZUu1CCU/5thirqS7DOILUpow ABKPjWDmFHYBhcH8HCYvQBZwvv1Vxyk1hd0sehTQBcsv2Dckr2aQqwkVZBoRCri/f9ma 3kyCh2nskDtgpRY+A+KbKJLHMr7MWfb9GSvh67L1+MgwBfQWZMWfL7By8YkqeKPctRGc pdkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680882524; x=1683474524; 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=Bvofdso7h4C0wbCuGQpq+8NVtokRUIZ6ky3V3PNneG0=; b=vDRAlXCCUkc4Te2ROzUpdVqAMmxUbtj2FvPGyDoXytQMoFHn2IXHjgb6eTGr/4tNZw n28C77aQf85vyYZEJy6+t/ZRpMDlvwHY0dVstkXlwI4UDe1N04mPaYEQDrltc2/gILvq mfVU/LS5jypSWnYsOoeJJKfirECK4aS17UQw+/LzRGvs8X6wX6gftsUbXG0djpU6bIGm T+apnjLgCmRC+Gkt6Pd5LJbC2aVoVofuTYcuYWPrpW3r5b6TjBLkZuujblKTpFsiVwSV Ec8pYSy48pDUQM2MMTM76/HdW13hWWWBhy+ocRrwAiCHV3UCPtLUJPbZg04GLQQJRIhk 0o7Q== X-Gm-Message-State: AAQBX9cmEqj/nKBrvoqLHy8RtBWYN81iq9jdSo+u3D2MM8R/uzuJ10d/ F3+/bkSF+RH3i2q7Jo0zi4gOHBBP6UE= X-Google-Smtp-Source: AKy350bLe1FW59P/4vvlykz2DGsyUiixloBEybTWDJDX7QqQWSCeG7bP8ED/tSCAql+uRecHRGgN5w== X-Received: by 2002:a2e:9214:0:b0:29c:9223:2f5e with SMTP id k20-20020a2e9214000000b0029c92232f5emr750160ljg.48.1680882524338; Fri, 07 Apr 2023 08:48:44 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v4 2/3] xen/riscv: setup initial pagetables Date: Fri, 7 Apr 2023 18:48:38 +0300 Message-Id: <2cbb70c8b29713f1faf235b4a90722d78bf258eb.1680882176.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680882549876100001 Content-Type: text/plain; charset="utf-8" The patch does two thing: 1. Setup initial pagetables. 2. Enable MMU which end up with code in cont_after_mmu_is_enabled() Signed-off-by: Oleksii Kurochko --- Changes in V4: - Nothing changed. Only rebase --- Changes in V3: - update the commit message that MMU is also enabled here - remove early_printk("All set up\n") as it was moved to cont_after_mmu_is_enabled() function after MMU is enabled. --- Changes in V2: * Update the commit message --- xen/arch/riscv/setup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 315804aa87..cf5dc5824e 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -21,7 +21,10 @@ void __init noreturn start_xen(unsigned long bootcpu_id, { early_printk("Hello from C env\n"); =20 - early_printk("All set up\n"); + setup_initial_pagetables(); + + enable_mmu(); + for ( ;; ) asm volatile ("wfi"); =20 --=20 2.39.2 From nobody Fri May 17 09:18:35 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=1680882551; cv=none; d=zohomail.com; s=zohoarc; b=UFiXkqEIQ6RyhzpT0JWwcXlYCRrb0EtQTOATV3y/NswusHb5kAtotU2CLH0tF8F8xP1M8/PIhHHWMEv6RN+RQM3bG+w5b8KOzDooMOz/5/JzpX8R8xRxBWvqldbNbTBuWf45DorOp5CVon3wx7CrHpmxoIXioTtn6iNa+vziMuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680882551; 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=dR16O0lugGTgYXlwGY6UhsQKrRSYw0CGkPTToCj++Ug=; b=TRl+edlhGHdAvRh/UmldMuyIkkQ38Ey7ixwgiRA6jJ299s0JumbtFF24DRg6VmxgIaGTrKGfGcTX3ZVxjo12siBzmUHsVYPxv/TouiZO8CimmD6sy7874ADTL3TGnU4aXEao8mbnSzbFO4iVE+Gf5tDpUKcpFxZW1xERPraoL/s= 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 1680882551032470.32968481149715; Fri, 7 Apr 2023 08:49:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519067.806238 (Exim 4.92) (envelope-from ) id 1pkoKW-0002LD-Us; Fri, 07 Apr 2023 15:48:48 +0000 Received: by outflank-mailman (output) from mailman id 519067.806238; Fri, 07 Apr 2023 15:48:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pkoKW-0002L6-Ql; Fri, 07 Apr 2023 15:48:48 +0000 Received: by outflank-mailman (input) for mailman id 519067; Fri, 07 Apr 2023 15:48:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pkoKV-0001rE-9T for xen-devel@lists.xenproject.org; Fri, 07 Apr 2023 15:48:47 +0000 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [2a00:1450:4864:20::22b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ae10e726-d55b-11ed-b464-930f4c7d94ae; Fri, 07 Apr 2023 17:48:45 +0200 (CEST) Received: by mail-lj1-x22b.google.com with SMTP id s20so23593326ljp.7 for ; Fri, 07 Apr 2023 08:48:45 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id v12-20020a2e9f4c000000b00295a583a20bsm874765ljk.74.2023.04.07.08.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 08:48:44 -0700 (PDT) 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: ae10e726-d55b-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680882525; x=1683474525; 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=dR16O0lugGTgYXlwGY6UhsQKrRSYw0CGkPTToCj++Ug=; b=WNtfsY4gAIKeRRXFCMruuMW9ZmEahyFB2wL7ubeBg+g9lGealukXMDfhRE1Y8sDvr1 XKpW8xy5x7dKsTnjBzJS9Th7BV7Y2rc5yvDVY4IsrCaRjqCRdzDm3hlymk4pJQN8JBO6 jF+ZvJivr55eMmvEhZhgP5sZ4tpik0pNAIeJ8ApqjKGIG3YEROX3SUxvwo+W2Ncg+QPK Or+Ws0WpsQ4fUmVsn0pUnxU2Zca34uwq2J16MO6bdpgjboqcJAf+zyznCgs1fssWos7B fUgtreelqzzAqy+Fgnqcq2al94r4uQMOmh5Dof4DmeOi1q5x5jyDqYlGNra3kfcEqB3a MhRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680882525; x=1683474525; 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=dR16O0lugGTgYXlwGY6UhsQKrRSYw0CGkPTToCj++Ug=; b=QzowfV09XlT4N7tuOWoTu1TCATz56kWehqiRKabg89IBOxtRZxNZWeKD1q/qSNJ3NI 8+N0tHIxzZEZnUmJG92Ymg+KNhv0XoaA60mDSe1F4rInbBWXyWoPAouE8RQZEdT/nJ4k IiegWpEBXDr/j7h3mFAEr97+q3dhj5jr6DvVYZorrTEw5LCSvRLyWkls/FbRrSmrCCT/ N+AsHewZJdGo/hgMW56CuFYbF0sb2ssam0DLIfttwdt8x1EDSgRx08/jahLPrGT2/arz E7EryCpKNGKWUd5bmSbEuh8sy1S/S7YRrVmZmyvbTheXfRLDSSuzzvVzLYDIyfhJJk0w 2clA== X-Gm-Message-State: AAQBX9fcB+5W5U69V3EZD91GPZLuutfiBM5w2OmcIsvRdYJG2fESAEMu LQluQ3TLqCs2M9HzV9COyHXyMoeOWH8= X-Google-Smtp-Source: AKy350bkZK1Y1VW7X1oCiqKF1QUHOQQXqi85UO/S8xap3BZ/klg3do3at0JUwxjNXS5JlXSehm7jmA== X-Received: by 2002:a2e:9dc7:0:b0:298:39f9:fb2f with SMTP id x7-20020a2e9dc7000000b0029839f9fb2fmr532236ljj.31.1680882525256; Fri, 07 Apr 2023 08:48:45 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v4 3/3] xen/riscv: remove dummy_bss variable Date: Fri, 7 Apr 2023 18:48:39 +0300 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680882551768100005 Content-Type: text/plain; charset="utf-8" After introduction of initial pagetables there is no any sense in dummy_bss variable as bss section will not be empty anymore. Signed-off-by: Oleksii Kurochko --- Changes in V4: - Nothing changed. Only rebase --- Changes in V3: * patch was introduced in the current one patch series (v3). --- Changes in V2: * patch was introduced in the current one patch series (v2). --- xen/arch/riscv/setup.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index cf5dc5824e..845d18d86f 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -8,14 +8,6 @@ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); =20 -/* =20 - * To be sure that .bss isn't zero. It will simplify code of - * .bss initialization. - * TODO: - * To be deleted when the first real .bss user appears - */ -int dummy_bss __attribute__((unused)); - void __init noreturn start_xen(unsigned long bootcpu_id, paddr_t dtb_addr) { --=20 2.39.2