Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2925229ybh; Mon, 5 Aug 2019 09:04:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxs1XSO4FNijeokhZYoFJKBPyUcacIuAu71O491idm8PsYGGhq+8YAVRpCFe/0T0zB3jnN/ X-Received: by 2002:a17:902:2ac8:: with SMTP id j66mr138566407plb.273.1565021043028; Mon, 05 Aug 2019 09:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565021043; cv=none; d=google.com; s=arc-20160816; b=dPqSLZxkVKOWr/U6+3oYJ74LJxmlJmm92Lq8pZe7BO7tcfsLyYKMyet1y+BGH5z5d6 TsFwkVrnWyOltRBhYHcI+VFZaUzgk0iHfpdEm3yKDJVPj18tMeDvrPzEA1s5H2G0Luca tggibZDqf9A9b5yKthkr/DDyOGNeBLpxlS/izC0qA2EXUy8PonqZui5hMK/a/xc2gvhF 8eUMyjhncx2RYnfLhFaO+8O6b3PAarPzZbKmZgGLHxMqy/dJUpzuy8uKK08egPqoY+sn 2IDZK/0+6ovHAl7xVSR43I6vo+KjtUiE6CQC2N8JWgvT7QZGTkgDsRkQQPZvuDfKEjNw EEuw== 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=LwK/9xcoxcLhVd0bC7/eyesTfSVbLSLef7bJ1QJeiPA=; b=xbJyKcnYUUrplpR08w+cM1+qUD3PqFeH9MhyW7c70LuDGwzqKKT3p8U3CXLYD27JPf AWD/P2vbUmMaSB3idnrOPlE26WoVHJJ8IhVB199gzf3x9Al8EgWfvhVJH/e8gLrTlZXm WlZcSo+xOy6X7NXOMrB7rtYMXHkytI9SsXCc0nWKJlkMUeQaPDMptJ/Xq2g8s47JJeLL 2wVwk8gmCeuEdtDmS3hWqaPXQy2AJXO+aSnIssGkJ2TkmpIMBqvmPjdJ8AIVh3VPLQgS 9aZwbkwnUp6aKiQnUGhAJcDi5RcapfisM5xhyt+oRPTPf4rXrVTOsy0Rugr49cJOYVhp OJjw== 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 k11si44294932pfi.3.2019.08.05.09.03.46; Mon, 05 Aug 2019 09:04:03 -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 S1728917AbfHEQDF (ORCPT + 99 others); Mon, 5 Aug 2019 12:03:05 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:39163 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727349AbfHEQDF (ORCPT ); Mon, 5 Aug 2019 12:03:05 -0400 Received: by mail-wm1-f67.google.com with SMTP id u25so63187242wmc.4 for ; Mon, 05 Aug 2019 09:03:04 -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=LwK/9xcoxcLhVd0bC7/eyesTfSVbLSLef7bJ1QJeiPA=; b=LVVGRxbhM84p4BY1nflnY85hASNh+Fj1eViiK5GYLqZSj4/WUbcFhBlRjkeoDoo4ca a6ErT0PcGG8RxNHYdyN/WdKPY9kdoD3pkN+iel6qPctJGPNYna4LXuJ7oYj8TZ4CiXT8 TBTIrwQnELZsTrpokVYLn0wkD5PVOnUpOnj0pbXLPu/icnr9AdJy79S2mWgLWA9dSFsZ T1ktJ5EV2Y0iL+FGRnn2xqDHa0xfN9FJzG+POlZOrcqfHVXzny66xforW0XcSIEV4R+p 0ZgRgFKYUQfbhZ3UrAu4NWNkfmwIdQGLlcRYlsxSsR1R+2QyJOxKemtJopwzJ3Y8ttDO C5ag== X-Gm-Message-State: APjAAAX4Z1GpizxSJXC7dKj7ioojAAXRBvEVyM33345hMNkxDutx+bz6 1Yysb532FKHxaiz6YFe2nt0HTsxIFng= X-Received: by 2002:a05:600c:1008:: with SMTP id c8mr19642061wmc.133.1565020983219; Mon, 05 Aug 2019 09:03:03 -0700 (PDT) Received: from [192.168.178.40] ([151.21.165.91]) by smtp.gmail.com with ESMTPSA id n3sm76821109wrt.31.2019.08.05.09.03.02 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 09:03:02 -0700 (PDT) Subject: Re: [PATCH v3 11/19] RISC-V: KVM: Implement VMID allocator 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: <20190805134201.2814-1-anup.patel@wdc.com> <20190805134201.2814-12-anup.patel@wdc.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <21bdde39-8d33-6aae-e729-476ce11406a3@redhat.com> Date: Mon, 5 Aug 2019 18:03:00 +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: <20190805134201.2814-12-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 05/08/19 15:43, Anup Patel wrote: > + spin_lock(&vmid_lock); > + > + /* > + * We need to re-check the vmid_version here to ensure that if > + * another vcpu already allocated a valid vmid for this vm. > + */ > + if (!kvm_riscv_stage2_vmid_ver_changed(vmid)) { > + spin_unlock(&vmid_lock); > + return; > + } > + > + /* First user of a new VMID version? */ > + if (unlikely(vmid_next == 0)) { > + WRITE_ONCE(vmid_version, READ_ONCE(vmid_version) + 1); > + vmid_next = 1; > + > + /* > + * On SMP, we know no other CPUs can use this CPU's or > + * each other's VMID after forced exit returns since the > + * vmid_lock blocks them from re-entry to the guest. > + */ > + spin_unlock(&vmid_lock); > + kvm_flush_remote_tlbs(vcpu->kvm); > + spin_lock(&vmid_lock); This comment is not true anymore, so this "if" should become a "while". Paolo