Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4623448pxb; Tue, 25 Jan 2022 14:48:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZeJ2WlM4y9AlV7iVTaMkQTuXkXSTwjNHVuBTMDqan6QgwrnxtX8lTsxUz80lhbqAPcr9B X-Received: by 2002:a17:90b:1d0a:: with SMTP id on10mr5584334pjb.167.1643150908906; Tue, 25 Jan 2022 14:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643150908; cv=none; d=google.com; s=arc-20160816; b=GSpd9sbe3drxcDnRG2yB8TTJWogpvJolyVF+CUMa38ppS28EutEOIPH6pkkYskbqi8 gQr4pyCqwflSuIrRxFV6AwzCc0rN+hnNo2asP5woXASzAbEIR4Yx1/mNSb2FTsJOtO1E ojEhSFrY+hmDvWTST4U2f7sQWxpo5DMH3+22x/OzQZkJl0qj+aBMl6fUuuC1OWEfDL1H C7OnTMm3WcnHN5T5dE4H9i5TjacWG6B1anIQUOOqWPZ2mtQ1YzToizVD7CdStg/V+ysY VszmhfsMSG5rDxa8atibUZrHPpC6On5h6bqEDGrG5tTGY+nZWE/wF+Q0F1SIJFyIIghb UQTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=Pg3ONRRG/SA5LY7eHpSKHXnF1/AmsovG6esXDptczBc=; b=K2JgiChKLqLM9TREB+/jZ3XCSojUgEY50NZbHZt6YESyK4deNL7JuAQfCOWBIZ0IGe 6Lut27zlqP4T0hVaPE8hZaRey98FjLzsVUWg77e7e1JjwKAk25EV4I09fbCHgsc5Gegf v0tUBsGe0+lMaCibNfXW6UebXgYEsqW6hMzosFNuCxz7KpeSRsLL1ifpyjNxs2a8dnl8 NcRwGR3PFpw8kGf3nfLzr+Bx4hrSyoQyYda/c7wVA4HIOSBgl0JM1tBKDQEJqVlwUHaT nPvXAJrorEb3UAf2MlXptYW6s0oq6vosI/gu0l//mDFeo1JX7FkvjO4ciPPE9NpREYtG +aDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uxCMXUS9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si16049988plq.494.2022.01.25.14.48.17; Tue, 25 Jan 2022 14:48:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uxCMXUS9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1581983AbiAYPTK (ORCPT + 99 others); Tue, 25 Jan 2022 10:19:10 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:49880 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359583AbiAYPQE (ORCPT ); Tue, 25 Jan 2022 10:16:04 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 25137B815F3; Tue, 25 Jan 2022 15:15:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5364C340E0; Tue, 25 Jan 2022 15:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643123756; bh=gld+cOICDVSyR3eBycE7Kw4pbeGx/5O8Kju3l/BFsZc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uxCMXUS9vU3rX/8c9OHaV7K9zy+vIlk9FYXci6vHqKNTHiqFFWa5VoQEPxjeSmo78 dVZK2zk2T8b97wcUmepHBWBZz9Z0YtsEbRF1hODLtXMlDNFe2pGycWZoBNY+6ebs9b uT18I/myxa1sQhLDgqtgZtjx5ofKpVmGDbq86OkbEUJdIMPB9QsAV4E9AXqg5es3Qt 9O+uvPMXRWMES2Z8cKYEeZQOSQ7HHZ+ujQDFUwLZnOk5Vr51p42emfZmN+rIK11EEJ UQ+UBvZ1roGlKILKO+1CeXAN3tpu2vKa53/41SWX9HD9V31UfvsB1eS7w4De7P55ji 4yY+q+2hMW/Eg== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nCNY2-002weW-Nr; Tue, 25 Jan 2022 15:15:54 +0000 Date: Tue, 25 Jan 2022 15:15:54 +0000 Message-ID: <87o83z7snp.wl-maz@kernel.org> From: Marc Zyngier To: Sean Christopherson Cc: Reiji Watanabe , Raghavendra Rao Ananta , kvm@vger.kernel.org, Peter Shier , linux-kernel@vger.kernel.org, Catalin Marinas , Paolo Bonzini , Will Deacon , kvmarm@lists.cs.columbia.edu, Linux ARM , Jim Mattson Subject: Re: [RFC PATCH v3 01/11] KVM: Capture VM start In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: seanjc@google.com, reijiw@google.com, rananta@google.com, kvm@vger.kernel.org, pshier@google.com, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, pbonzini@redhat.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, jmattson@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 Jan 2022 00:07:44 +0000, Sean Christopherson wrote: > > On Fri, Jan 14, 2022, Reiji Watanabe wrote: > > The restriction, with which KVM doesn't need to worry about the changes > > in the registers after KVM_RUN, could potentially protect or be useful > > to protect KVM and simplify future changes/maintenance of the KVM codes > > that consumes the values. > > That sort of protection is definitely welcome, the previously mentioned CPUID mess > on x86 would have benefit greatly by KVM being restrictive in the past. That said, > hooking KVM_RUN is likely the wrong way to go about implementing any restrictions. > Running a vCPU is where much of the vCPU's state is explicitly consumed, but it's > all too easy for KVM to implicity/indirectly consume state via a different ioctl(), > e.g. if there are side effects that are visible in other registers, than an update > can also be visible to userspace via KVM_{G,S}ET_{S,}REGS, at which point disallowing > modifying state after KVM_RUN but not after reading/writing regs is arbitrary and > inconsitent. > > If possible, preventing modification if kvm->created_vcpus > 0 is > ideal as it's a relatively common pattern in KVM, and provides a > clear boundary to userpace regarding what is/isn't allowed. No, that's way too late. The configuration is in general per-CPU, and I really don't want to expand the surface of the userspace API to allow all sort of magic trick depending on the nature of what you save/restore. The "first run" crap is already there. We have it on a per-CPU basis, and we need it at the VM level for other reasons (see the recent discussion about PMU filtering vs binding to a specific PMU implementation). M. -- Without deviation from the norm, progress is not possible.