From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 915E417F375 for ; Tue, 14 May 2024 16:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715702740; cv=none; b=mSDdym6jF44CBDFBQjuM5bQH9znmAObxR4fXcfs0cCUf0U2byawTfmHJ12kqVUTFprAvglX9YQOSHsuZaH5qBY6rMq6jxh5vxljPmZ5uo8c3LBVnh42rwOG9kwPrEmFTaSFMRifH5waZwnA5NkqfqGXy4vKp1mMBr6f4zRtFXuw= 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.180 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 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: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5d4d15ec7c5so4862549a12.1 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=si5cT1gp3bxeXiXQM4UmQwiQboVGXkR3OBMGtXIx8fT4Oje+ohj13vBERiZuum7U14 V4p9PKEavfu6GK9fRa68kfeIQL3PoIi2NKsrie5g0m5TCrmfgWLkhBBcwlCA5r+EHFIn dfReqiFO9jiVLoAEzqOhpIqLwy360c9NE4Z7whJja2C2xhYHPwR94UFA8aZhjAy7kSxu OP9cIWsImjWV6+sVJuXMmjkKX197qwRPZjwEA3iL+ObSJ/ten0zGPpE/5bZkSDsWIuxU IaIfGHUcT8K2q0JhI/xyzz8lohWiy9ldMoJYTtEUxuJHi5qBTX1SjSarU69E11d1Zd+8 rvnQ== X-Forwarded-Encrypted: i=1; AJvYcCUXBiWBMP16UZZGXHgzYzXGzW1Djn+VhkSSRsfpwqhFYxb7/0La+i4B42OfhBlXAQ8wPvX/hDI5Pg7L+YdvQQemZ0mT0HcxBjhyjg== X-Gm-Message-State: AOJu0YzQUircX7KeBk4YBYbqebNhol9onzDI7cCfsonPNY/i9mc2RxDr ixJMSME20pEpu1jrzZhv5amqGIJ09IGFYxdDCj1k5k0y2kpTc4/QGze7dsP/oM0= X-Google-Smtp-Source: AGHT+IExT0Lpton62tmUoqhHHjwgEPqRSbd+czbDp3DyV4MKZCvZWeoGNi2mbvNDBuZ7uGZamR5c7Q== 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: devicetree@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 >>> >>>