Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2787139lqo; Tue, 14 May 2024 09:06:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbHPFB3qYorJfJpr/DzUyKt0Oeq6nNn3XpvED08RIUpePqSyMVgHC/AVU8tBv65bRMs3nfeLtD/RD2p9Sssgl2vBfwvM9Fgdf79GwTuA== X-Google-Smtp-Source: AGHT+IF3nJ+2cbfNTgkmcZ8s176tqRW0szLyQhjR+qHjAcSGrhvkntRCUulj/c53+dCKsVxcE4gQ X-Received: by 2002:a17:902:ce8d:b0:1eb:7ba:a4c3 with SMTP id d9443c01a7336-1ef43f4e4a0mr210588265ad.48.1715702772036; Tue, 14 May 2024 09:06:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715702772; cv=pass; d=google.com; s=arc-20160816; b=fSmFQy810KN0p3AQEWBpk+/yejAXuvgz3mzftccJJAhhctjrJLIrCDagrbHNFk1i1Q fTJAI6+b+udyGJ9PIVCuD4l0TC+wkXgCf90TYm4nKQsDnpCyfeAw5qTEgYXYqnebTUwQ hYnJXEe15AwZZhfRzRFM799kYghG0HX65fZpub8pJ5C+oeItnMbb+9J+aKjjDoDvl/RE VNAogtp8/+6HwbKhpWZw06mMnMUzDuAwLOoMNy3qrAMKEe8LXLQHI92YC8DhWpfZ6vlr xHDGyf7bRPNXWAyLK2TWC74d4Dt0nZ0CgcDIo9MKhCMmkODKuqb4k0YZCPqoHr0wTs0x XZXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hLYpzcxGm24wBNcj3TBbz1d4cmvEZCPvDGA2meO1iLY=; fh=JXUQwe+zn7vQZwgsPxlQvbTS+vB0y+Aj6RL/U9TmBlU=; b=n2eM7vgq2mvCCTE6lM53Nbvo1owXYZps6ENOvuhqqnvt+cT4L9YFzL4NBgnMJMOPov PBGPBtlQrtOsCf15JK+izAeHYhFNf3nmQQUgSCqMwFoXqoTye2tsouzfOw6s9QAFu3/U nHbKOj7XcIwRKzVQuHiCN5DmaVZC9e8bQ5nCbhdBoeHQ4qJPvTH5QHOafDoM/+I4siL7 32mZ6PGAcAziV+BTZVizmoTTOJzEuLLGqkPTGti6rbRUyykGnGDm0BmzEgBMn6ccXcTj KqJNUUBOQq3XKcZI6GfNa6VZQzv80cBObMjNSuFF3p29aHEQ7lJQvGup+GnAQw+zpqlW 4v5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=oSYLkKnE; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-178906-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178906-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c26749esi123150125ad.566.2024.05.14.09.06.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 09:06:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178906-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=oSYLkKnE; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-178906-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178906-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 EA5FC2830BC for ; Tue, 14 May 2024 16:06:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D45C61802B2; Tue, 14 May 2024 16:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="oSYLkKnE" Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (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 8BCA817F370 for ; Tue, 14 May 2024 16:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715702740; cv=none; b=GspP5TikoCUcwsUynNg03YOJks64rB9gPWHndRIFgNm7t1mKiBffHnhml1AoU1ScEQaw9ATxG1Ya+rAeRX78YR1I2eFLi/TRpAm+BjGyqy1JDoDUbUwuG9mO6buFHDnGOjgZpXO5N1uh26OqMCvSoXYrBVPsC8pEFE8agb/1mpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715702740; c=relaxed/simple; bh=hLYpzcxGm24wBNcj3TBbz1d4cmvEZCPvDGA2meO1iLY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BRj8y5xdEcX2sF84CdDgK/qw3rH7YkxbINEl8wbylH1q5do3ONtOT0hJ0C6lKmIAO9qGiUi9W029ZC1p1owueAaviQEangO9yj/63aDMjKJ3laKWHs1OVSH61HOH7oOu9CdTzmjUUdIhflynlL9U89ul6OzaTs6StitwxdUu8dU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=oSYLkKnE; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-5d8b887bb0cso4664628a12.2 for ; Tue, 14 May 2024 09:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715702739; x=1716307539; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=hLYpzcxGm24wBNcj3TBbz1d4cmvEZCPvDGA2meO1iLY=; b=oSYLkKnEjs4owzHCt1bnwht/7oUeabeVWw0rRO17H/m0obHAEab0F5VHpWx5AUm0dw IrD8/SuWsZ2cq0FeR4mvawmKRMDEyfeTHKsMuhumy6AvuM/kwGUPgzSetRwaK4BuEOXf NndwDm6mdPhrXP1XWa5TQmGs9E1CWczp7zRzzuELLfT2vmpWZZNv+W85WUVb3UPEe9JJ 4m7crweJ5MSQnaz8TFlT2vHS7Q61L0XrSHe62HToeByuH+arDCY2hnwTNw5j89OphKcQ nNtYsgouaE0et2lTeKkkUsKqElhydU9ixE4A2I9m3io7ytgcnGLphOrOoY/yy9cErTRB NT0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715702739; x=1716307539; h=in-reply-to:content-transfer-encoding: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=hLYpzcxGm24wBNcj3TBbz1d4cmvEZCPvDGA2meO1iLY=; b=tCiokaJgRugbyQ4cI42VKDHu3chuCF0SHTgMJkrt7BKEYWHfT3TM4ZO214A/6ExZXr th1leerCK1ik4PMujar4VswPeI9fMXBmCOosOJfi6HWmHML1sTPrj3hXHlC6ph2llhg2 La+/+lg3pVDaaevLIyjJXbbQGyMemXTF/2vTnPoreQyItTIqaCOjXnVaICgfJdrBC89/ GaqKletQYMMC/Wr36c+2bxC6GqpK4sSrFxxave9i+q6tM4mbfAVSJfVLUtiglPDkLK+i 5AlL79gs+R2LkVOqlJ/oAynPWyz1/JGy3qpPCl0zf4kRIFKrQepP7VKDRSzgMT3IMvkn xi7g== X-Forwarded-Encrypted: i=1; AJvYcCWvF7ttOpRdZ+4VuB9WL8yHZxtQt0F29i7s/kFwF7DK/co3imkHrc4mDhi9++dmWMrpjPmxonRJ2DwRh5BZD8vR4EzYNEdj8C5fVtky X-Gm-Message-State: AOJu0YwcI3JcJDdXP5gax9BDY4kyChpm2PG4N2Lva3At0T7Jj0nq3k/U DXnFjhYqd8mbJmx6Cko6wd+T7G1XxC5W1AhPhxz5kCXe+CssWXCTZu0AEOKLA+lbJoYNspCQ6Kb I X-Received: by 2002:a17:90a:51a2:b0:2b4:329e:e373 with SMTP id 98e67ed59e1d1-2b6cc45030bmr13858119a91.6.1715702737681; Tue, 14 May 2024 09:05:37 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b62886b669sm11734330a91.24.2024.05.14.09.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 09:05:37 -0700 (PDT) Date: Tue, 14 May 2024 09:05:35 -0700 From: Deepak Gupta To: =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Ved Shanbhogue Subject: Re: [RFC PATCH 6/7] riscv: kvm: add SBI FWFT support for SBI_FWFT_DOUBLE_TRAP_ENABLE Message-ID: References: <20240418142701.1493091-1-cleger@rivosinc.com> <20240418142701.1493091-7-cleger@rivosinc.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=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, May 14, 2024 at 11:43:15AM +0200, Cl?ment L?ger wrote: > > >On 27/04/2024 03:17, Deepak Gupta wrote: >> On Thu, Apr 18, 2024 at 04:26:45PM +0200, Cl?ment L?ger wrote: >>> Add support in KVM SBI FWFT extension to allow VS-mode to request double >>> trap enabling. Double traps can then be generated by VS-mode, allowing >>> M-mode to redirect them to S-mode. >>> >> >>> + >>> +??? if (value) >>> +??????? csr_set(CSR_HENVCFG_DBLTRP, DBLTRP_DTE); >>> +??? else >>> +??????? csr_clear(CSR_HENVCFG_DBLTRP, DBLTRP_DTE); >> >> I think vcpu->arch.cfg has `henvcfg` field. Can we reflect it there as >> well so that current >> `henvcfg` copy in vcpu arch specifci config is consistent? Otherwise >> it'll be lost when vCPU >> is scheduled out and later scheduled back in (on vcpu load) > >henvcfg is restored when loading the vpcu (kvm_arch_vcpu_load()) and >saved when the CPU is put (kvm_arch_vcpu_put()). But I just saw that >this change is included in the next patch. Should have been this one , >I'll fix that. > > >> >> Furthermore, lets not do feature specific alias names for CSR. >> >> Instead let's keep consistent 64bit image of henvcfg in vcpu->arch.cfg. >> >> And whenever it's time to pick up the setting, pick up logic either >> perform the writes in >> henvcfg. And if required it'll perform henvcfgh too (as >> `kvm_arch_vcpu_load` already does) > >I don't have a strong opinion on that point so if you think it really is >better, I'll switch to that. Thanks. > >Thanks, > >Cl?ment > >> >>> + >>> +??? return SBI_SUCCESS; >>> +} >>> + >>> +static int kvm_sbi_fwft_get_double_trap(struct kvm_vcpu *vcpu, >>> +??????????????????? struct kvm_sbi_fwft_config *conf, >>> +??????????????????? unsigned long *value) >>> +{ >>> +??? if (!riscv_double_trap_enabled()) >>> +??????? return SBI_ERR_NOT_SUPPORTED; >>> + >>> +??? *value = (csr_read(CSR_HENVCFG_DBLTRP) & DBLTRP_DTE) != 0; >>> + >>> +??? return SBI_SUCCESS; >>> +} >>> + >>> static struct kvm_sbi_fwft_config * >>> kvm_sbi_fwft_get_config(struct kvm_vcpu *vcpu, enum sbi_fwft_feature_t >>> feature) >>> { >>> @@ -111,6 +147,11 @@ static const struct kvm_sbi_fwft_feature >>> features[] = { >>> ??????? .id = SBI_FWFT_MISALIGNED_DELEG, >>> ??????? .set = kvm_sbi_fwft_set_misaligned_delegation, >>> ??????? .get = kvm_sbi_fwft_get_misaligned_delegation, >>> +??? }, >>> +??? { >>> +??????? .id = SBI_FWFT_DOUBLE_TRAP_ENABLE, >>> +??????? .set = kvm_sbi_fwft_set_double_trap, >>> +??????? .get = kvm_sbi_fwft_get_double_trap, >>> ????} >>> }; >>> >>> --? >>> 2.43.0 >>> >>>