From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mx.groups.io with SMTP id smtpd.web10.1082.1685143060804256981 for ; Fri, 26 May 2023 16:17:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@ventanamicro.com header.s=google header.b=Mpb93/g9; spf=pass (domain: ventanamicro.com, ip: 209.85.210.172, mailfrom: tphan@ventanamicro.com) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-64d41d8bc63so1252703b3a.0 for ; Fri, 26 May 2023 16:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685143059; x=1687735059; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NsCsA13ODrfJ5VysMwXlxXifDOPhvuienm2HzJqJNw4=; b=Mpb93/g93QE951cTBOy9wnpWCcD2cg/c6iy7+uwGxAaVVMOX/Exx34V9qt3b9KHEag iU43Ago6R+MvgD9vHWUEMtNZta03vahGnCPoglsbVdxxscXQtH08gPoL9Us5L604sjyX fMM++E0EHRyTzSnpoPgMHyOoFEDUTMcKx5z0bOHQXFZ+D3M5N/WqistbuLKMM3vm2FFO 7U3aYtDEVFB/xgsrdSCVua0/2/Hzl67LVw5GHTlEGm4ijwfTmdmb6yqdo8yW08iJEqyz Q1OkY/CA3zUBjYw2T85ZFDe6y/DZWLvAF10JOf9SyyHZjK3os/IZxNrTPaa+X1/TgVeF xULQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685143059; x=1687735059; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NsCsA13ODrfJ5VysMwXlxXifDOPhvuienm2HzJqJNw4=; b=f33oBi2jLAcF3Jq3107gro3Ysl1w/hw8sjzG05KJ7OGN7Ch7tBOIrrdB3uXh+dQxwE LjyaM6vJOi1tswcpMYug6yPZ8Dmx+/IzdTrIgT26j+tJr64ibhAGmoz7IAvHpZ6HYWmG n7b+xxlmWrlRbcfi7HSIUm2t7uBhqQ5nmAP9ZVnjlExkHUbz48QCt8Qm2sawCr0M+apm cdwMmUdKcbvoKTIgyOHV8UZiUQECMwPpLHPjO1Id+WRWmJCqqwkaGiStdz8bKkqhs9Kc Ou/YIcWNFzLa+zoIRzmGoJzGszanFilmvCfEsxvhqk84PGvTNZW8xNYzN87mfe90jKkw 5lFQ== X-Gm-Message-State: AC+VfDzmGSpYZUGDZjRuaMTKWgZqsM9+qUSqz4EdS9UXb6cX8VVAMRUz tmTRIOB25a5YBOP/2P4wRozdtV2ck36LsmyubIc= X-Google-Smtp-Source: ACHHUZ5rf9vCgT4OA/gR4txKJBi9Zi0GPxT5Q36JVil+CWeCqXtJOIcgKL70QPo/awZcAFxYkmuUqg== X-Received: by 2002:a05:6a20:869a:b0:10b:fb01:a72a with SMTP id k26-20020a056a20869a00b0010bfb01a72amr889287pze.60.1685143059562; Fri, 26 May 2023 16:17:39 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id k3-20020aa792c3000000b005d22639b577sm3106308pfa.165.2023.05.26.16.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 16:17:39 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [PATCH v3 0/7] RISC-V: MMU support Date: Fri, 26 May 2023 16:17:26 -0700 Message-Id: <20230526231733.6755-1-tphan@ventanamicro.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RISC-V: Add MMU support This series adds MMU support for RISC-V. Only SV39/48/57 modes are supported and tested. The MMU is required to support setting page attribute which is the first basic step to support security booting on RISC-V. There are three parts: 1. Add MMU base library. MMU will be enabled during CpuDxe initialization. 2. Fix OvmfPkg/VirtNorFlashDxe that failed to add flash base address to GCD if already done. 3. Fix all resources should be populated in HOB or added to GCD by driver before accessing when MMU enabled. All changes can be found in the branch tphan/riscv_mmu at: https://github.com/pttuan/edk2.git Changes in v3: - Move MMU library to UefiCpuPkg. - Add Andrei reviewed-by. Changes in v2: - Move MMU core to a library. - Setup SATP mode as highest possible that HW supports. Tuan Phan (7): MdePkg/BaseLib: RISC-V: Support getting satp register value MdePkg/Register: RISC-V: Add satp mode bits shift definition UefiCpuPkg: RISC-V: Support MMU with SV39/48/57 mode OvmfPkg/RiscVVirt: Remove satp bare mode setting OvmfPkg/RiscVVirt: VirtNorFlashPlatformLib: Fix wrong flash size OvmfPkg/VirtNorFlashDxe: Not add memory space if it exists OvmfPkg/RiscVVirt: SEC: Add IO memory resource hob for platform devices MdePkg/Include/Library/BaseLib.h | 5 + .../Include/Register/RiscV64/RiscVEncoding.h | 7 +- MdePkg/Library/BaseLib/RiscV64/RiscVMmu.S | 8 + .../VirtNorFlashStaticLib.c | 3 +- OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc | 1 + OvmfPkg/RiscVVirt/Sec/Memory.c | 18 +- OvmfPkg/RiscVVirt/Sec/Platform.c | 62 ++ OvmfPkg/RiscVVirt/Sec/SecMain.inf | 1 + OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 25 +- UefiCpuPkg/CpuDxeRiscV64/CpuDxe.c | 9 +- UefiCpuPkg/CpuDxeRiscV64/CpuDxe.h | 2 + UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf | 2 + UefiCpuPkg/Include/Library/BaseRiscVMmuLib.h | 39 ++ .../Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c | 569 ++++++++++++++++++ .../BaseRiscVMmuLib/BaseRiscVMmuLib.inf | 26 + .../Library/BaseRiscVMmuLib/RiscVMmuCore.S | 31 + 16 files changed, 777 insertions(+), 31 deletions(-) create mode 100644 UefiCpuPkg/Include/Library/BaseRiscVMmuLib.h create mode 100644 UefiCpuPkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c create mode 100644 UefiCpuPkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.inf create mode 100644 UefiCpuPkg/Library/BaseRiscVMmuLib/RiscVMmuCore.S -- 2.25.1