Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1260136pxk; Fri, 25 Sep 2020 10:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA/fHRcqCmC+2L1HK58hPUpjeO0j+9paBO/4lCK66gI3f/hli5/YEGw1hZsHAZuL35Aiw4 X-Received: by 2002:a50:fc87:: with SMTP id f7mr2344794edq.162.1601053430832; Fri, 25 Sep 2020 10:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601053430; cv=none; d=google.com; s=arc-20160816; b=fV8mxCC7uOVd3B7aBxLKb7bWGSe3+tUG8habeOjAV6yPNbBNNod20G18POQm2/CCvw Bp9K8Fcj9/WdHhPsjMpzq9HKtg39Oqehv1rG+bHId0+E2e1pKpu1aP2B3s+dsrO6Y5ls dTpmJhD0y6YaY0VFas+5cKJHuqgqTVkQdWEFRhMNtTouM5px8j6qSkUQt2123mYBE4sN TNK+t0xvooF3z66JWI/UdJEnH9XPiFHKiIKDvskSrzDT+CafF4sIbCyE5vkGht0GrNoc zfTvRsNwfmvZ6xUkTHaJTq0OEGms5KztG1/2bWfptAMBxUoyNnyIX4q4OdQP4Ff93sda VYiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=x/ntvfmFfbPKIzs40LEU/13aWYuFhMj2vxAfoW6ncnI=; b=tNTRPg4kErxN0n9JpJFhgjgjm7Am8N4I45NREE4ycwmF10AHrfwTNrYvef1/LDJI/2 qJLFaBWE0jR5wTnIY3EHxSKw8wSjSmQnpt2KyErd/SI5NKm/n7S7re5rJyPkwqZrm5Da 71Ky9sAETQUEv06sgh9UI56kj5Mb4Tb6QscFvwuh9laA8yRPQnR9TeLasp2vkhKaLuHC ba3GGdQ3mo2TguXvKi6xdYxYbpaXlTbexjaqe9SXW7HqnpU3uJAgt0ptsymHTbIODkuU CBgtgZ3Xq+GsnHYmgkvuBvANO6A3KVTPqqvPbj+EyzyJVFv1XKIAGdSIImoNSpIsmTii ir0g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f9si3027989ejl.32.2020.09.25.10.03.25; Fri, 25 Sep 2020 10:03:50 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729445AbgIYRAr (ORCPT + 99 others); Fri, 25 Sep 2020 13:00:47 -0400 Received: from mga02.intel.com ([134.134.136.20]:2149 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727151AbgIYRAr (ORCPT ); Fri, 25 Sep 2020 13:00:47 -0400 IronPort-SDR: HdzKTVl1mHh9/M7UVqUkbo+8YCG0n/AprBsd6UTurIRUNQUVSvTng8ezp0WQAv+oWBEcMsep+x AfKroZxOmdDw== X-IronPort-AV: E=McAfee;i="6000,8403,9755"; a="149236260" X-IronPort-AV: E=Sophos;i="5.77,302,1596524400"; d="scan'208";a="149236260" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 10:00:44 -0700 IronPort-SDR: 6N8ivLkqnnd2bn5U+j4zqY15q1XntncTtYZH1JiR4NLnvBVXx96w0CnbSmk4HwsES3EEo7c23V rfEb4OHh8buw== X-IronPort-AV: E=Sophos;i="5.77,302,1596524400"; d="scan'208";a="310885499" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.160]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 10:00:44 -0700 Date: Fri, 25 Sep 2020 10:00:42 -0700 From: Sean Christopherson To: Marc Zyngier Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Huacai Chen , Aleksandar Markovic , linux-mips@vger.kernel.org, Paul Mackerras , kvm-ppc@vger.kernel.org, Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Claudio Imbrenda Subject: Re: [RFC PATCH 0/3] KVM: Introduce "VM bugged" concept Message-ID: <20200925170042.GB31528@linux.intel.com> References: <20200923224530.17735-1-sean.j.christopherson@intel.com> <874knlrf4a.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874knlrf4a.wl-maz@kernel.org> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 25, 2020 at 05:32:53PM +0100, Marc Zyngier wrote: > Hi Sean, > > On Wed, 23 Sep 2020 23:45:27 +0100, > Sean Christopherson wrote: > > > > This series introduces a concept we've discussed a few times in x86 land. > > The crux of the problem is that x86 has a few cases where KVM could > > theoretically encounter a software or hardware bug deep in a call stack > > without any sane way to propagate the error out to userspace. > > > > Another use case would be for scenarios where letting the VM live will > > do more harm than good, e.g. we've been using KVM_BUG_ON for early TDX > > enabling as botching anything related to secure paging all but guarantees > > there will be a flood of WARNs and error messages because lower level PTE > > operations will fail if an upper level operation failed. > > > > The basic idea is to WARN_ONCE if a bug is encountered, kick all vCPUs out > > to userspace, and mark the VM as bugged so that no ioctls() can be issued > > on the VM or its devices/vCPUs. > > > > RFC as I've done nowhere near enough testing to verify that rejecting the > > ioctls(), evicting running vCPUs, etc... works as intended. > > I'm quite like the idea. However, I wonder whether preventing the > vcpus from re-entering the guest is enough. When something goes really > wrong, is it safe to allow the userspace process to terminate normally > and free the associated memory? Yes and no. Yes, there are potential scenarios where freeing memory is unsafe, e.g. with TDX, improper sanitization of memory can lead to machine checks due to integrity errors, i.e. freeing memory that wasn't sanitized is not safe. But, our in-development code intentionally leaks pages that couldn't be sanitized (with plenty of yelling). So, "no" in the sense that, IMO, KVM should be written such that it's sufficiently paranoid when handling "special" memory (or other state). > And is it still safe to allow new VMs to be started? Hmm, anything that is truly fatal to the host/KVM should probably use BUG() or even panic() directly. E.g. to avoid a userspace bypass by unloading and reloading KVM when it's built as a module, we'd have to set a flag in the kernel proper.