Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp297886pxb; Tue, 29 Mar 2022 04:15:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL1JxICfZi+cYtzA/Yx52KB/Gprh07Bxf+qT4INmxz5zxYx8xcldjS+cLjbQNDDHm6RFBc X-Received: by 2002:a05:6402:50cf:b0:418:ee57:ed9 with SMTP id h15-20020a05640250cf00b00418ee570ed9mr3839109edb.37.1648552557581; Tue, 29 Mar 2022 04:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648552557; cv=none; d=google.com; s=arc-20160816; b=0nPu5GPnrHy5kZcP3s2ayEIm0Kf7DBeDpIFhh1V/bgfMIECeihO9fWsjRNV9wtDVzg 36p1AGVUiQIoWguzMm8m44EyjlzpS4tzawelCAlclzfgA/5uDxtcy6ia8TlFHV7vLVPd zVCFj36z25oBcf2NsMIZkhq8byhxtX+Iu0ISrKTZVT9Zpy4Wh17HKzIidtaKlA8i13/J bLXbkKoYrSZABOKMM0qaIOURk4NtJ8Ft5WHQTJ0pxR9u076bCDLEqZRf3qQZNfdmkzm/ Q0xW4BIBttkdtno8n23sgoBautxoQNVyD1XKdcNxYYWkJkWOtxOFqmQXW5KjTzVf36JS MOBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ppNdA/FhRD9g5++0K+Ya9WXyfU57mPy49sftAdzbp8w=; b=TMLzTY2aou2RywKpxIj/dnwlMIojaDGNtnKd2AX4MCe2bd37i/iHhr1s5mY/Z0On7M 7oLsPbQs8QGftT+f1U/+gc/ujktXR43h6fRT7Oc6Jz1z9WNT1BZkqBNpnHTLv5Wb/DNT id2N8WcUlXdhs/FS+/6yW+WwMF+HJMIUSHLZDyLXPPBa9dowd77EJhoc19vfyXk7rqxu c22lme18irBCKCdGETsyoFhFXhDVy3Emr+4WhopXus11Ou1jUhHo/lMQvSN4m2kb4WsB Jk571aAi294FfKUX10KSxpUBBFVnQ+NjlziLyjPQfF8OTmGSE3ZCR/rjZQLLQmUR0CoL phHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=gcxsu0qk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo7-20020a170906d04700b006df76385e33si17128253ejb.723.2022.03.29.04.15.18; Tue, 29 Mar 2022 04:15:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=gcxsu0qk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233410AbiC2HbT (ORCPT + 99 others); Tue, 29 Mar 2022 03:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbiC2HbP (ORCPT ); Tue, 29 Mar 2022 03:31:15 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 523BF2AE6 for ; Tue, 29 Mar 2022 00:29:32 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id i11so5580476plg.12 for ; Tue, 29 Mar 2022 00:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ppNdA/FhRD9g5++0K+Ya9WXyfU57mPy49sftAdzbp8w=; b=gcxsu0qkGm5afdR5CecI5Kj8Oz6i3fcQWabAOBtFVeKspQqMZnaPQbPXsIka/7QqWP 9OQkwOZjEs6rHriQ+9z/OPi20q/Ls2Pux0FjbNwIgCvCXXYtnsgC8xiERCIKs3aauJZq 2SkeykXVA4WYN1kV0ltpa77beaHtqiG9ZyqBK7s8kixX9iZxBVWaN9lKrwl2GqZmtUiU PjadOpN8iLSAn/qFU3U+L3zUGR+Q1cix9aqfgtreFrCpzQbxt772CqygJoxK1ysRSwVr h1bYIcV2FfMvpzAAkgIhlfwE/JWw3yyDlBi1bjfO7AdG8Ajtx8PEIbh/4N7Bjshf2yVa pheg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ppNdA/FhRD9g5++0K+Ya9WXyfU57mPy49sftAdzbp8w=; b=bj21XY3DXCnLOl3OEf0SY8lFbvwMNALvaVuqn3PbATyRE8bnGGbLMS9ik/g0YWVQ5g NqSwgD0RwYGTpltuYIT8/UIgETMU14NAXoZGIS4fHZ7TMBkiSbw+8CSyujH/tnEyRf6t +hNwuoQv8FMVIppHAZpxisFY4WzJoJTA+ttt7L7tM7QH8dueFyU4MdAeOv4Cb1Cz/ye2 J0Mz/93twFHzcwyuuu36j5CfFzb4bAg8Qk1qdF3gQFoRxC/VXeJ+NcEFeJWIy5JL5fCL +pOSgOQGYDn+svT7uIpwRWwpttR0NJKOb+xpstrxndLv93odm/bq0Er+2K6G4/nicVxL S4Tg== X-Gm-Message-State: AOAM533kcedrU48Kunzv0wnp0xFjvasBR+ZnaMV3EjzBKwQOSt5zTiEa Gor3auiB6AQZUmpBbUA4qjiy5A== X-Received: by 2002:a17:90b:4b83:b0:1c9:6d37:38b7 with SMTP id lr3-20020a17090b4b8300b001c96d3738b7mr3124696pjb.21.1648538972341; Tue, 29 Mar 2022 00:29:32 -0700 (PDT) Received: from localhost.localdomain ([122.171.166.231]) by smtp.gmail.com with ESMTPSA id z6-20020a056a00240600b004e17ab23340sm19440564pfh.177.2022.03.29.00.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 00:29:31 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Alistair Francis , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH 1/3] KVM: selftests: riscv: Set PTE A and D bits in VS-stage page table Date: Tue, 29 Mar 2022 12:59:09 +0530 Message-Id: <20220329072911.1692766-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220329072911.1692766-1-apatel@ventanamicro.com> References: <20220329072911.1692766-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Supporting hardware updates of PTE A and D bits is optional for any RISC-V implementation so current software strategy is to always set these bits in both G-stage (hypervisor) and VS-stage (guest kernel). If PTE A and D bits are not set by software (hypervisor or guest) then RISC-V implementations not supporting hardware updates of these bits will cause traps even for perfectly valid PTEs. Based on above explanation, the VS-stage page table created by various KVM selftest applications is not correct because PTE A and D bits are not set. This patch fixes VS-stage page table programming of PTE A and D bits for KVM selftests. Fixes: 3e06cdf10520 ("KVM: selftests: Add initial support for RISC-V 64-bit") Signed-off-by: Anup Patel --- tools/testing/selftests/kvm/include/riscv/processor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index dc284c6bdbc3..eca5c622efd2 100644 --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -101,7 +101,9 @@ static inline void set_reg(struct kvm_vm *vm, uint32_t vcpuid, uint64_t id, #define PGTBL_PTE_WRITE_SHIFT 2 #define PGTBL_PTE_READ_MASK 0x0000000000000002ULL #define PGTBL_PTE_READ_SHIFT 1 -#define PGTBL_PTE_PERM_MASK (PGTBL_PTE_EXECUTE_MASK | \ +#define PGTBL_PTE_PERM_MASK (PGTBL_PTE_ACCESSED_MASK | \ + PGTBL_PTE_DIRTY_MASK | \ + PGTBL_PTE_EXECUTE_MASK | \ PGTBL_PTE_WRITE_MASK | \ PGTBL_PTE_READ_MASK) #define PGTBL_PTE_VALID_MASK 0x0000000000000001ULL -- 2.25.1