Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp728140pxb; Fri, 14 Jan 2022 15:08:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyY63fnAK1Be29lgBTqNHu+LL0+7wWKhepIt1/ayk9NW3bhEnYYi6VlXY1erOt+kZuq5PWw X-Received: by 2002:a17:906:e20e:: with SMTP id gf14mr9133882ejb.319.1642201735288; Fri, 14 Jan 2022 15:08:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642201735; cv=none; d=google.com; s=arc-20160816; b=wgAfAdhp2SOWmucsPFunyO8ionN72ujXJCyRI+g7SkzVBFksL/b2RFfnDVgMUPCafw d5yGU5jzUi/6j26CaqJn431JBC206np6NKpP2QM30KGAZOErfzpXJb1YmP/hwgvrxhS+ DpIDBOXXELaAYIEeUqTDHHQkTPXo1CfAkaKlqKb9Vl95U093nkUMpZpUWeZrB0gyW88F AZ0+rTnyFk3JxEb9KiyQJhBW5vX2eQYVb08sTNHNOfzy2V+fIdEhkuxwDjOogPx45gHg /TNK2XJ1OJCNrZaVbQa0wjztq+ihEuN3gLrdAADTZE9Klz7NJDqkoXtYlQC10m1tTL5Y oEbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CDsGS2jq8SAFd9OvPx49AGjFg/2s2ed5RyEVXzRWnAo=; b=X7r8+rD7Dl7LV5PHLzo7AGlXTh3b93cZz961Ki9N9rC40rXufYINlhp21Myz9mh++O GVsCEYujkC10ZdVp5n6cnLM59R9xCnlvI3DAoEpE2vik8fuPtzqf7SS2Ogp92M9TxuVb bHeJOc3ij+eGScPXbYWFOcqiQzo/Z1Pl+3WbF7WF1Gv3iM00YjkCnLZ0Mq3TeAcNvSIA KXfmQlrQi0xUkSC4aq8kf8MzVcqTKrVcD9mIDYGlfNidf6Pj4PbeIj0lhxcjQOS0qlxE hvsGNwBS7qC8Ebur99mrsfH3BdWjGg3RXgwwmwp6G3XwlpMwy7c+cABFEhLJwcCH7OZl mDyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cfjpva8b; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si4600803edd.21.2022.01.14.15.08.31; Fri, 14 Jan 2022 15:08:55 -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=@google.com header.s=20210112 header.b=cfjpva8b; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbiANVvZ (ORCPT + 99 others); Fri, 14 Jan 2022 16:51:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbiANVvY (ORCPT ); Fri, 14 Jan 2022 16:51:24 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7222C06161C for ; Fri, 14 Jan 2022 13:51:24 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so15453234pjp.0 for ; Fri, 14 Jan 2022 13:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CDsGS2jq8SAFd9OvPx49AGjFg/2s2ed5RyEVXzRWnAo=; b=cfjpva8bdcPLTTQoIPCixVnAFaxsDELlb/9JwStbXYQvRDZGYhfWD3/1KeCmYuq1Yy IupWGk+fR/uoJLiecnN6JvPjTin7H2Hska91lSfi0kRro7XHjZ6Rzw5/PBWb3KmK74HI 6pCTKoDjaCjUtQcw4EmIb5Vfnyj3Gkuo0vj2jqbXi6WAKriAHyY1Sgq+jO+4eA5weoen ZrIWRe1oHnOOA/6QybWEb2IdUiv7mV9Bj9zx4zNCcwBb//Iynkc59wxBPmD0p9oUP07a L+eJCdTyRQg1pRPFhhLwPjoPg8fhQ884XaKcHU6+jI7Zd1mjfSkV4huFnNNCOGyPSI2t Jc6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CDsGS2jq8SAFd9OvPx49AGjFg/2s2ed5RyEVXzRWnAo=; b=eNNA4SRnssr3Ur6LDMkAuahTC24Q+Wn2Pif9mYRwt1I12uoz7pok2qwqRyF2/QQuDV jgkgLjE4NhlmHulKJmcxg5U9/vfNGKLGgmvdg4w5v0R9orxndbdtbzwSABmuWVJYXMCs 1MsAucvW2mhxB0YUTgbOORcWee2uk2+uOOo+EuQamiWhX2nw6Cj0VJal2FoHdRU3EExi WTMiBSeSB/uaZeR4jzMH5P+EVlXEbspUWP6RYXV2Iwe02/lNsGQPPkJEiSXXwpB84bmW zPkWOg42/CziubeUQZtiu2LaWpisIRpE4fwbThS6cEaF/K1MLUwF37snRNRKdkz6L+Je YrkQ== X-Gm-Message-State: AOAM532DaGpDyj3vXPM81bcZRixYljWZSY7EaCarnxkFEUZUSDsVfF3F EaT+tAVsmwxFuJR4jqMjwRO3iVrFmTKKm/2NrhBWcQhVtJC/FA== X-Received: by 2002:a17:902:ea10:b0:14a:6c29:a6a5 with SMTP id s16-20020a170902ea1000b0014a6c29a6a5mr11540567plg.172.1642197084066; Fri, 14 Jan 2022 13:51:24 -0800 (PST) MIME-Version: 1.0 References: <20220104194918.373612-1-rananta@google.com> <20220104194918.373612-2-rananta@google.com> In-Reply-To: From: Reiji Watanabe Date: Fri, 14 Jan 2022 13:51:07 -0800 Message-ID: Subject: Re: [RFC PATCH v3 01/11] KVM: Capture VM start To: Sean Christopherson Cc: Raghavendra Rao Ananta , kvm@vger.kernel.org, Marc Zyngier , Peter Shier , linux-kernel@vger.kernel.org, Catalin Marinas , Paolo Bonzini , Will Deacon , kvmarm@lists.cs.columbia.edu, Linux ARM , Jim Mattson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 13, 2022 at 9:21 AM Sean Christopherson wrote: > > On Wed, Jan 12, 2022, Raghavendra Rao Ananta wrote: > > On Tue, Jan 11, 2022 at 11:16 AM Jim Mattson wrote: > > > Perhaps it would help if you explained *why* you are doing this. It > > > sounds like you are either trying to protect against a malicious > > > userspace, or you are trying to keep userspace from doing something > > > stupid. In general, kvm only enforces constraints that are necessary > > > to protect the host. If that's what you're doing, I don't understand > > > why live migration doesn't provide an end-run around your protections. > > It's mainly to safeguard the guests. With respect to migration, KVM > > and the userspace are collectively playing a role here. It's up to the > > userspace to ensure that the registers are configured the same across > > migrations and KVM ensures that the userspace doesn't modify the > > registers after KVM_RUN so that they don't see features turned OFF/ON > > during execution. I'm not sure if it falls into the definition of > > protecting the host. Do you see a value in adding this extra > > protection from KVM? > > Short answer: probably not? > > There is precedent for disallowing userspace from doing stupid things, but that's > either for KVM's protection (as Jim pointed out), or because KVM can't honor the > change, e.g. x86 is currently in the process of disallowing most CPUID changes > after KVM_RUN because KVM itself consumes the CPUID information and KVM doesn't > support updating some of it's own internal state (because removing features like > GB hugepage support is nonsensical and would require a large pile of complicated, > messy code). > > Restricing CPUID changes does offer some "protection" to the guest, but that's > not the goal. E.g. KVM won't detect CPUID misconfiguration in the migration > case, and trying to do so is a fool's errand. > > If restricting updates in the arm64 is necessary to ensure KVM provides sane > behavior, then it could be justified. But if it's purely a sanity check on > behalf of the guest, then it's not justified. The pseudo firmware hvc registers, which this series are adding, are used by KVM to identify available hvc features for the guest, and not directly exposed to the guest as registers. The ways the KVM code in the series consumes the registers' values are very limited, and no KVM data/state is created based on their values. But, as the code that consumes the registers grows in the future, I wouldn't be surprised if KVM consumes them differently than it does now (e.g. create another data structure based on the register values). I'm not sure though :) 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. I thought this was one of the reasons for having the restriction. Thanks, Reiji