Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2160858lqb; Mon, 27 May 2024 09:39:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOttUyN4qS+B3RP2NcQnYpwS8250NZdNr4tIA6X1NdQsK9slVCIJkxofLeWWRvFXBi+AZ/56rSUOvs3eL6L45jgBv6NaLKOxV9rj7MMQ== X-Google-Smtp-Source: AGHT+IFl9seOxWeJQqhxJ83zNtuNBW5g85CYOGlhzFu1b33mfGdt45utw4/sgKfUJ23CcL5ZvhsA X-Received: by 2002:a17:90a:e007:b0:2bd:e8d3:8808 with SMTP id 98e67ed59e1d1-2bf5f10aa16mr8513647a91.49.1716827982927; Mon, 27 May 2024 09:39:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716827982; cv=pass; d=google.com; s=arc-20160816; b=pcw+o1w8gmFR0wNWK20If1mnefwUk5gXdygAecnDLhoRg6UoGpgcAdLSXcP0eUO6Br +xw1v6raGfOxnuuL4+kSfmGyK12P0AQBbqx9mPTzQkOktx7Dhmgg6iAEkVvGZ/NGBDNl 1TnId4u+Qokmh/qkvyOmpKXQy35o6Hs8HmVxd5rx6UPt7P2X0OITnKY4F3KWw3o8ZbM6 AI+KbtPWEcqK7XuykL/Z2sKhsTRXb75FDi/WvmQNvl5l030uVHTA/t4N5hecQ4kSkjAe nwXzVrDaJY0M9TYJsQ4JAAxbdG9J/+z6J5s93fPPXKIZ5OFsXrVB6e5rYkHniGnsZP/l Rzuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CUR9tjUj2iCuKOML1r+nyycL1s+FksIs6kJ9krg7rYI=; fh=iRSQdxhqgGxeDrGx+vgmooD0cHD0QvmBl9IjXUCWqeY=; b=EIBFC+zY0e74jpy4Wk9TP7gz5PYvNW7+Zp+86CdUXENwdol9F5s/EgxytmF8pCH+5x kZdYczCkcaH2XcuGqq/u/ajxuO7Zo8DRbArg1k3zJs8htLUFJoUINoTbqUG5aENB7+93 8qvGzV/GBU/G+CDoBriR9O40w/uRs6xlBUOa+zU0mwporKtnrgQqVdK5UPjUPju76Nfn mU/5BSNpoU0k8ogSlP8UA9t5kw863uPGitfbIas37IA9F0N2ueRdKcoy6IdAJ8krMCWI ZnJ00DdPy9RhxplCM9rMuuVb7SoudT+vIQzm27kMinr97fbyy3QomEcYSs6958eZe6Lt T6rA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WXOvQ+bP; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-191239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191239-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bf5fac632csi6531193a91.37.2024.05.27.09.39.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:39:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WXOvQ+bP; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-191239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191239-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CC152282654 for ; Mon, 27 May 2024 16:30:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B9E0155CAD; Mon, 27 May 2024 16:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="WXOvQ+bP" Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA4D773441 for ; Mon, 27 May 2024 16:29:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716827379; cv=none; b=oTainxIr1nA3xClaodxpe9t/p9CZRUAPJL00q8TAsUUthhUDoLmOAjoyJckuwfFhVuNog+TmTw7K6PLUw0o99mo7e9W2oWigm9w0Kof17X0p8bye8c27WMlA8fwcMFph7TjR7kJtI0SZidAY1YYIt5vH2NP2NYBR9FGButjna70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716827379; c=relaxed/simple; bh=rk2XezkAzS5gUv8DwWyuJeBuEahdoVMELENJgT+Z7VQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hzrxI0EJi9cM3LbYmuJb+IwFpO+Zrrw0XZylTiyXf8Sm2T4XNVTfKXpj09T8JNCnw0+msdRhNE30GqnH5sZZYwgwZPFRd2gWT6BAH8XbohU12eklWx8uieQw80PLU9nzlzzqk2QiTs5FxDptD3FdGQ1DyyGGrm6ZU8H4KU4SlBk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=WXOvQ+bP; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-420180b5898so80523495e9.2 for ; Mon, 27 May 2024 09:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1716827376; x=1717432176; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CUR9tjUj2iCuKOML1r+nyycL1s+FksIs6kJ9krg7rYI=; b=WXOvQ+bPyuPJqHwU4+icL8ySqXFsBfKb6V7+Fr1Z5DYSVcuU2KQIR+PT0kjUr7tJoj 3ACAtlM+p62nYlhjqDTf7brKkgvhKm/g6g6BdzfW793OIIx+iOi5cfxUv+B7JeFHbczP T5kOye6/JNCkTBa7dYGKjWRPzp51/2q0OGD3/9airPAWnOXaJM8uwUs0xi3TlSDYh91Y ob5d3H95pg+Qt8aFfEqvzV0/qtLqVSjqgnnC5Bf61NyCHBQJl1G67GnML5uQWPl4C/v7 8CwngJyq9vhlsNZbGVLRFHsW61z92Db+n5ss6sHCFPtTXIkQKWJT+uTkzp0Y350YRyM/ TGRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716827376; x=1717432176; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CUR9tjUj2iCuKOML1r+nyycL1s+FksIs6kJ9krg7rYI=; b=Svu2sct9vn4IQBc/IE/2FQcG+09Z83shJ/fF+mMeyGzkHWGG6Kk+FTd+hrUnwwzl4K 9FRWcN/0P/zUx36OEDJIkNrUuPzqQuNL1oC718vDa9GKj3RDgZNLqDwDVSmLqIUddR0t KIP0gl8XJpvBCsithMWV4uo5XeQDrzXt2AfXF+OLF0w//aXkkst81eFzQ7dCrIR5z5eo Qz5vjApMVr3chYG9I3YIPVLx+94y+o74O3JA7dRCavvI/376PfRXMCVQdr1xpyCXvshj Fj9TvqNi8WyXABl86fqQl0zKN5AgpDQvjXvalnzWltzSdMYuY6bSHqNiB5sp9TwFbm2g 4R8Q== X-Forwarded-Encrypted: i=1; AJvYcCUpzw7hLFRaPBnULSKF6JvNziI5FrG7gT+1SE637wHs6z7UVGV7ZASgnSFO1PNtpEO4NKLorP/oyWFugmjFBqDjmLsjZf5zHzjYfi2I X-Gm-Message-State: AOJu0Yw2P8/hhrOckgyInnu5Squlw53OgJzawWF1KY4FnHnFNPyRy4Uf rSL6aClWlrGNZT2t3iU6vLLfbQF+CqhHdYwdAXlszCKei67PWm95DdbqiYUSddA= X-Received: by 2002:a05:600c:1d22:b0:418:2b26:47a3 with SMTP id 5b1f17b1804b1-421089ffc9emr76330215e9.32.1716827376450; Mon, 27 May 2024 09:29:36 -0700 (PDT) Received: from localhost ([176.74.158.132]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-421089b0410sm113439735e9.29.2024.05.27.09.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:29:36 -0700 (PDT) Date: Mon, 27 May 2024 18:29:35 +0200 From: Andrew Jones To: Yong-Xuan Wang Cc: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, greentime.hu@sifive.com, vincent.chen@sifive.com, cleger@rivosinc.com, alex@ghiti.fr, Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v4 4/5] RISC-V: KVM: add support for SBI_FWFT_PTE_AD_HW_UPDATING Message-ID: <20240527-cd06bb4215d05129f4793dd6@orel> References: <20240524103307.2684-1-yongxuan.wang@sifive.com> <20240524103307.2684-5-yongxuan.wang@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240524103307.2684-5-yongxuan.wang@sifive.com> On Fri, May 24, 2024 at 06:33:04PM GMT, Yong-Xuan Wang wrote: > Add support for SBI_FWFT_PTE_AD_HW_UPDATING to set the PTE A/D bits > updating behavior for Guest/VM. > > Signed-off-by: Yong-Xuan Wang > --- > arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h | 2 +- > arch/riscv/kvm/vcpu_sbi_fwft.c | 38 +++++++++++++++++++++- > 2 files changed, 38 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h b/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h > index 7b7bcc5c8fee..3614a44e0a4a 100644 > --- a/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h > +++ b/arch/riscv/include/asm/kvm_vcpu_sbi_fwft.h > @@ -11,7 +11,7 @@ > > #include > > -#define KVM_SBI_FWFT_FEATURE_COUNT 1 > +#define KVM_SBI_FWFT_FEATURE_COUNT 2 > > struct kvm_sbi_fwft_config; > struct kvm_vcpu; > diff --git a/arch/riscv/kvm/vcpu_sbi_fwft.c b/arch/riscv/kvm/vcpu_sbi_fwft.c > index 89ec263c250d..14ef74023340 100644 > --- a/arch/riscv/kvm/vcpu_sbi_fwft.c > +++ b/arch/riscv/kvm/vcpu_sbi_fwft.c > @@ -71,6 +71,36 @@ static int kvm_sbi_fwft_get_misaligned_delegation(struct kvm_vcpu *vcpu, > return SBI_SUCCESS; > } > > +static int kvm_sbi_fwft_adue_supported(struct kvm_vcpu *vcpu) > +{ > + if (!riscv_isa_extension_available(vcpu->arch.isa, SVADU)) > + return SBI_ERR_NOT_SUPPORTED; > + > + return 0; > +} > + > +static int kvm_sbi_fwft_set_adue(struct kvm_vcpu *vcpu, struct kvm_sbi_fwft_config *conf, > + unsigned long value) > +{ > + if (value) > + vcpu->arch.cfg.henvcfg |= ENVCFG_ADUE; > + else > + vcpu->arch.cfg.henvcfg &= ~ENVCFG_ADUE; > + > + return SBI_SUCCESS; > +} > + > +static int kvm_sbi_fwft_get_adue(struct kvm_vcpu *vcpu, struct kvm_sbi_fwft_config *conf, > + unsigned long *value) > +{ > + if (!riscv_isa_extension_available(vcpu->arch.isa, SVADU)) > + return SBI_ERR_NOT_SUPPORTED; > + > + *value = !!(vcpu->arch.cfg.henvcfg & ENVCFG_ADUE); > + > + return SBI_SUCCESS; > +} > + > static struct kvm_sbi_fwft_config * > kvm_sbi_fwft_get_config(struct kvm_vcpu *vcpu, enum sbi_fwft_feature_t feature) > { > @@ -177,7 +207,13 @@ static const struct kvm_sbi_fwft_feature features[] = { > .supported = kvm_sbi_fwft_misaligned_delegation_supported, > .set = kvm_sbi_fwft_set_misaligned_delegation, > .get = kvm_sbi_fwft_get_misaligned_delegation, > - } > + }, > + { > + .id = SBI_FWFT_PTE_AD_HW_UPDATING, > + .supported = kvm_sbi_fwft_adue_supported, > + .set = kvm_sbi_fwft_set_adue, > + .get = kvm_sbi_fwft_get_adue, > + }, > }; > > static_assert(ARRAY_SIZE(features) == KVM_SBI_FWFT_FEATURE_COUNT); > -- > 2.17.1 > > Reviewed-by: Andrew Jones