Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp995421ybi; Fri, 2 Aug 2019 07:40:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwox7TLkRefVjVdXKokS8lCwkYQqmE4PzsL0Jc+n2wbcsV3DHK3Lp0BfIULVVw15V0PBTbO X-Received: by 2002:a17:90a:9301:: with SMTP id p1mr4682602pjo.22.1564756820269; Fri, 02 Aug 2019 07:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564756820; cv=none; d=google.com; s=arc-20160816; b=kOhgC+dt5Uc3IgS+qq0yzOBcGxqbdv19QbFet5V8QePa2jhZWR3z40WyY2J6d+8Rli KgVYNUXXTuuLSJ2t57mcaFTUI5gQbc258w8P7Pgj0Bkdg7BAgDhFyxhCcDkX4hBMH92e FT3971JLJ1/4I7YGrMZZkhJ8BAImlmntyuchMsBQzn7aPRfBP3x9hCOMxU4O8Gl8EOyN bWIcg9IFWmv/lmsNAAl2vPFe7M1+JgZd45ZX8NlRCD9oB9L/HChq/6rLsRqKh8nJ5Jm/ whgdVFWHOic1tzBo1dms6wgtKC80az72CADVwyW3ns9cRyfGdeU0NJ/gTYt7GyM7sy3A T22A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=Bwx8/3+omec7zmijOtKif9DQxXapLJoupah+QfmoXjM=; b=Cd+mdBFEcJKxqzOrJ6eIImf0J2ryE7pH6ZTiA9Z5J+woZB792T6hy7+8iNVYNUQU5g J/ktwWvLluVyczEYtl7fINH7PZgaWDPMFptfiF7JJLHVyXu/7MePhgMnG1dfMIt0Uuqz u8VbKblaDDYizpxggo1HLXT2iBHPSkP05i/rgukfmsnXH5K+5f2GmDpMtpiGo0eiXg3S gZ2DuUPHYMM3n0FEy0BoN65vmvFZxlWdvWWWMhsFmLZgsqzrmmjjFkECzSrdmvTglmk4 8/K1/HIqscPmqhawk5Du3kvnJee/Wy3NptMT4F6fwpWzwUoqExuETSCdFJo9prQ7Kxhb WP3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si1302430pgp.69.2019.08.02.07.40.00; Fri, 02 Aug 2019 07:40:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404602AbfHBJDs (ORCPT + 99 others); Fri, 2 Aug 2019 05:03:48 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46783 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404594AbfHBJDr (ORCPT ); Fri, 2 Aug 2019 05:03:47 -0400 Received: by mail-wr1-f66.google.com with SMTP id z1so76347733wru.13 for ; Fri, 02 Aug 2019 02:03:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Bwx8/3+omec7zmijOtKif9DQxXapLJoupah+QfmoXjM=; b=g8FcP7JknYEE1sKM2vKWm8K7gy6qq+XCKyGs7BwLM8+t461q4pRXZrhMwdqrInQ9ws w6wvLn51kNbVft1bSTxy6zAzBxrqzvndOHdQlWVbnm/PXxQqZQfaprpkWSsu+fz4Pwhr z3J+nTydkqx7kKNYa04NKPqK6lIbhYqhbgvMuz/QqZsfxz/ps18J00cX+EqTFkB14Oh4 UDSkEmuj0Hm77lhZQ05V6DC6vglpB63hAP26vnm1bOd1p8eBCyfPzjFsCFNclmGfQDV1 /Zy0QbT969/sStbd2iisxnHAo8i3vN/Nc9fEqVvfXlQx5JkEIdE1eFFvBg11RvqyXkKw YvHQ== X-Gm-Message-State: APjAAAXefOW8EcBRm031QXye9yyZV6JOZj0gobThg+n+qMee2YF19g1Q YwelppH5tHsscFvxm9wf2ochwPz/9zI= X-Received: by 2002:a5d:4e02:: with SMTP id p2mr36191018wrt.182.1564736625330; Fri, 02 Aug 2019 02:03:45 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:4013:e920:9388:c3ff? ([2001:b07:6468:f312:4013:e920:9388:c3ff]) by smtp.gmail.com with ESMTPSA id c30sm140911490wrb.15.2019.08.02.02.03.44 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 02 Aug 2019 02:03:44 -0700 (PDT) Subject: Re: [RFC PATCH v2 07/19] RISC-V: KVM: Implement KVM_GET_ONE_REG/KVM_SET_ONE_REG ioctls To: Anup Patel , Palmer Dabbelt , Paul Walmsley , Radim K Cc: Daniel Lezcano , Thomas Gleixner , Atish Patra , Alistair Francis , Damien Le Moal , Christoph Hellwig , Anup Patel , "kvm@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" References: <20190802074620.115029-1-anup.patel@wdc.com> <20190802074620.115029-8-anup.patel@wdc.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <03f60f3a-bb50-9210-8352-da16cca322b9@redhat.com> Date: Fri, 2 Aug 2019 11:03:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190802074620.115029-8-anup.patel@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/08/19 09:47, Anup Patel wrote: > + if (reg_num == KVM_REG_RISCV_CSR_REG(sip)) > + kvm_riscv_vcpu_flush_interrupts(vcpu, false); Not updating the vsip CSR here can cause an interrupt to be lost, if the next call to kvm_riscv_vcpu_flush_interrupts finds a zero mask. You could add a new field vcpu->vsip_shadow that is updated every time CSR_VSIP is written (including kvm_arch_vcpu_load) with a function like void kvm_riscv_update_vsip(struct kvm_vcpu *vcpu) { if (vcpu->vsip_shadow != vcpu->arch.guest_csr.vsip) { csr_write(CSR_VSIP, vcpu->arch.guest_csr.vsip); vcpu->vsip_shadow = vcpu->arch.guest_csr.vsip; } } And just call this unconditionally from kvm_vcpu_ioctl_run. The cost is just a memory load per VS-mode entry, it should hardly be measurable. Paolo