Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp916889lqt; Fri, 7 Jun 2024 02:36:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7xADcjOWzZXQCZC4FAUHJPAocjVgYhtxoiXeA4muz6TTNRA087a1lhSUVvw1YdMlMdNSR7TheE81ywlwbhAFD49GXi0byI8RjBSU+ZA== X-Google-Smtp-Source: AGHT+IEIMtxZOzbicn6Mcy2eKzu/sy6dwgFopziIgDhoi5YblXPtho9KDXau7At+LCY7WKjXFDYb X-Received: by 2002:a05:6a21:7885:b0:1b3:fb21:2960 with SMTP id adf61e73a8af0-1b3fb212ae2mr661113637.30.1717752984113; Fri, 07 Jun 2024 02:36:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717752984; cv=pass; d=google.com; s=arc-20160816; b=suojXjK7+oLKOjldYhivWhSs7T9Z7p/TuCTWs2spS8uO8rx2Iozx0oRXHvltBOe3NM +roiOEUdypjt8qLJWkVbPZyVgme//FKG1fATdbwrNX6Um0a5GglT653Q+x8xSK471iZx u+N6rwzzvGw/u89PQzFV+NX4yZPW0nj+rZ4UNWdPkpUe/LdmzWDnzj2MiTHS4emWnFSK 1CueVzzZ7nr4g37x0YsYhQS8EakeCl7vVMS61t39XKbjoIFy8XLaidC0eKv0X2U884IK ydVkt/ssTjKwLKC6sHFafDSh2cvgV5qRxwICB6e+17diY2fXoFnm0a3FRhhYd6VevxfM VuVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=8CLx8I7uIS4yN2qY8IP79uDVs9k1SwxKuZrHLU/16hk=; fh=AJfGk6c4gGoJiICGdF8J4+4CIXjFT/l/zGrntjblQ0Q=; b=O3reD/TiKzzDqpprHyDO1SwRBravkoMIgdakahcnUoKao+dQPJ2Tx4aySbHIFZ3VkD dz1EZ80m0tbV/VCuJ25w15yNSv4YvbmWKE0U4qMpXKz0AUR1uufEqTFbbFhhOtm3817T xsgJKQSyKhsCV+JX4Y0oDeEqd+ccdim2uULhF6AEKObvTj7Eacd6+a812xcOGWAWwPbF aWHpU6UgwfkkwCiramV9EQ59CL2bY7PK7joMBpaqemlInHLA64aLCpS6x6mRTPojUicB YOoHybK5O2w3yNoOA9HzuLCIUiAeOY/peIAY/cx1CULzxMcqBDu5vu1FwfS/beWT8OgR ohng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=dz4Wbqm4; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-205495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205495-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 d2e1a72fcca58-703fd4d1d9asi2720122b3a.147.2024.06.07.02.36.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 02:36:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205495-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=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=dz4Wbqm4; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-205495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205495-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 D8D49292A7E for ; Fri, 7 Jun 2024 07:10:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEE3B155748; Fri, 7 Jun 2024 07:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="dz4Wbqm4" Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) (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 A2306153578 for ; Fri, 7 Jun 2024 07:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717744034; cv=none; b=fPIXwfGEyNvJtF+I77+iih/+bcCrJ3965/hcwTM7o7MWNIRI/49x4BPfs58AjSbUKGDKKx0IYBuBjX0e89akwpvHH1VyVJy/nutXfCsTMOd/F22JtW/rGir98EHyOPOrNklz0A8ER+K3mGwXDSgDN7FFr6gjKfXyfDJJrZuvqjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717744034; c=relaxed/simple; bh=uDKsXWnZBq8B1TZSbGrBofUZF8hvuJaCCCMe9c3tno4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=j8gKL0TZMd07BkgjrjVFJbPiRVTHqdh6a2S7XdsGxd+AeHoXwaUyX2A5iKAtc3eoUk5Ny6vTv38Jr3goqu2pegp6fs0SLxWu94pECCTuVxTH86mSLzgUAJkwMIYLgdub/E9ohyUEVm5oI+TRrktG7ILztdUg1tbq6AzDuBw9tuo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org; spf=none smtp.mailfrom=brainfault.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b=dz4Wbqm4; arc=none smtp.client-ip=209.85.166.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-375833acc98so1260515ab.1 for ; Fri, 07 Jun 2024 00:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1717744032; x=1718348832; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8CLx8I7uIS4yN2qY8IP79uDVs9k1SwxKuZrHLU/16hk=; b=dz4Wbqm42Bp05zD47ZT5UJX5xNZD2rHUqo2J5ey6CCNtibMXbhYzHBZhM80zEb+Ed+ moeaEH16tN8wYgyesy/ZoccwkUTa+FLo3f8GcBTC4VEkTmeIe+0TwZP0m/l2LPkcp0sb MxpCYALqvOj9FGaWdZBJpDqQ9qlaHJTak7pfs6NZVlwGdE+8t3kAKd0BS15gI9WO1Xsv rxAWmqvR5XYIkKZkUfQ4Lkz7CO7jdHrZkG7YoRGtbQN2PXmx0zPp3BALadVJN2xhMsVN +72etnPkar/szOeg7ZxdkLwuoOaol71KoJHlj4ZoJXFNKjWHsxroguMsbr/6rSdDPrhm hqDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717744032; x=1718348832; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8CLx8I7uIS4yN2qY8IP79uDVs9k1SwxKuZrHLU/16hk=; b=wvM6HI1RsBejknMlFoGxqzZkM2yTO2vHJ9PuUc8TEpTlSO3naNgOOQFlj6wKUYHJ+7 fml2rEhTBc0M8u2OonDrltstxk9Y8Qjk22iTqkXvNCehuzO8sxtQjMO2HeqQSG9qjj9t Y5UXz20Xb6eGcQxTE3zXIfzRqf6voky9iFq8Bp1ahxnplNk4zj4AsAJXci3Z2yhqxX2n 1Wzj/5UJjVLj0rKGKFzhcnO9u0HRblCmw/eR8WDWE4WjWj2mf2mlu5vkQgWnI20Q+BhP 7sm9sj3cXwyYanWWvIOBcbDRHEqFowyT25dWobc99jM6nzBXMspkV85wiRPI+DgILWSi hA9g== X-Forwarded-Encrypted: i=1; AJvYcCWJ/JhVjo4vUviwyO2cfR/Q3UdkcENKVbWKVx5FFDkjhpKXKblPL6Qfr06LML0zcRxx1RpXZ/It+P7ud8eCiB0JsffTzaJOUuN8zAlx X-Gm-Message-State: AOJu0YxxgTquW5TaLHD5U1de4Ai/6MPt07nQfrynXAQfJJYWyP0w4RdR CbSUQlpMB4nBkS10XzqadX7jit3l0vhTpqGfNu5MXshdu/B8PoOPUAOEXhioWUrgM/NziFRVBAf HaieGfesy7dWvd4xpWf+rT+PDPgMn7sPd5fZG5w== X-Received: by 2002:a05:6e02:20e8:b0:374:9e82:7b51 with SMTP id e9e14a558f8ab-375802fcc9bmr22082355ab.9.1717744031764; Fri, 07 Jun 2024 00:07:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240429092113.70695-1-betterman5240@gmail.com> In-Reply-To: <20240429092113.70695-1-betterman5240@gmail.com> From: Anup Patel Date: Fri, 7 Jun 2024 12:37:01 +0530 Message-ID: Subject: Re: [PATCH] RISC-V:KVM: Add AMO load/store access fault traps to redirect to guest To: Yu-Wei Hsu Cc: atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 29, 2024 at 2:51=E2=80=AFPM Yu-Wei Hsu wrote: > > When unhandled AMO load/store access fault traps are not delegated to > VS mode (hedeleg), M mode redirects them back to S mode. > However, upon returning from M mode,the KVM executed in HS mode terminate= s > VS mode software. > KVM should redirect traps back to VS mode and let the VS mode trap handle= r > determine the next steps. > This is one approach to handling access fault traps in KVM, > not only redirecting them to VS mode or terminating it. > > Signed-off-by: Yu-Wei Hsu Overall this patch looks good to me but the patch subject and description can further simplified as follows: RISC-V: KVM: Redirect AMO load/store access fault traps to guest The KVM RISC-V does not delegate AMO load/store access fault traps to VS-mode (hedeleg) so typically M-mode takes these traps and redirects them back to HS-mode. However, upon returning from M-mode, the KVM RISC-V running in HS-mode terminates VS-mode software. The KVM RISC-V should redirect AMO load/store access fault traps back to VS-mode and let the VS-mode trap handler determine the next steps. I have taken care of the above at the time of queuing this patch. Reviewed-by: Anup Patel Queued this patch for Linux-6.11 Thanks, Anup > --- > arch/riscv/kvm/vcpu_exit.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/riscv/kvm/vcpu_exit.c b/arch/riscv/kvm/vcpu_exit.c > index 2415722c01b8..ef8c5e3ec8a0 100644 > --- a/arch/riscv/kvm/vcpu_exit.c > +++ b/arch/riscv/kvm/vcpu_exit.c > @@ -185,6 +185,8 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct= kvm_run *run, > case EXC_INST_ILLEGAL: > case EXC_LOAD_MISALIGNED: > case EXC_STORE_MISALIGNED: > + case EXC_LOAD_ACCESS: > + case EXC_STORE_ACCESS: > if (vcpu->arch.guest_context.hstatus & HSTATUS_SPV) { > kvm_riscv_vcpu_trap_redirect(vcpu, trap); > ret =3D 1; > -- > 2.25.1 >