Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1037336pxb; Thu, 9 Sep 2021 18:42:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXGJnwVjE0PlRfx5dN3HRCnqkTTmQcIsgp+6oM4ILxSBBM3t1ZxBOHJIPwul6UJnSDrq2L X-Received: by 2002:a17:906:8506:: with SMTP id i6mr6657255ejx.397.1631238174604; Thu, 09 Sep 2021 18:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631238174; cv=none; d=google.com; s=arc-20160816; b=T9yEUdHgPDrx8mMXvWyiTWGYHNR5MVww8TFgEmbLTEv8hNbcfz5RRSXw6gs/s3M6Qs q0nKoYYDMGP2Cym7kqzADG08yGhOJexEV92WvM8qRONPayEP9FcwrcWOB5RhdGHVHH+U KpLjRlGewTY2e/Jr37IUpCsglSVclhBcK7GZ8qRyfhlbq4PcE70IoJ86s20pZhsvMA9f Q+dE5RSblt1Q4N3XfvI1/8dBofOExogd6J+Osguz+vRK1EdjkPOyTq0JffnV21ftjBXL Ns1QlCUy2g8ufUkZyIOM1R3TFgkq3i/y42kYi6d/jMscN0/8J8AlzoIo0nqfgsVAfvpV J6MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Nw1XuRphVhmebMWySqSgscevY/3iUqmrlDyrnRFrHKA=; b=DJzjgy3xGLmbAA4f1SLbMrMcwycYCDmGF9/OjF62tLuU/KWmP10RiR3UqlOtjGc1+g ALtJvf5PuqnjIRP2LqDV5YYuFFKY5aSexufQMpvXLl9d/zkIyqn//2eGoaydBvmtf0gI WQqtpokg9SoUd46rOrlpgIqrhGeaIqJebpq5sUplLwR0f0Xm8ZIXChJZs1Y4XwTXFgF0 ZSkwSYVe8s1ptu/QKxjo7rVkgQfo9xTKIHl0SWkZzgWUp0HeZFLmtG3fnbkeUw722rFT 3KUpZC9+W0IpjgMT8Yi8bU1QllzgaOSsf4rsBIGyy3DH2F9LHhwfOqIVAEYzbmxptLgA aUtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=S5YmgtMQ; 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 26si3603123ejl.648.2021.09.09.18.42.30; Thu, 09 Sep 2021 18:42:54 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=S5YmgtMQ; 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 S230302AbhIJBlT (ORCPT + 99 others); Thu, 9 Sep 2021 21:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbhIJBlR (ORCPT ); Thu, 9 Sep 2021 21:41:17 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DE70C061574 for ; Thu, 9 Sep 2021 18:40:07 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id r2so370677pgl.10 for ; Thu, 09 Sep 2021 18:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Nw1XuRphVhmebMWySqSgscevY/3iUqmrlDyrnRFrHKA=; b=S5YmgtMQkCudzpyQLODl0re3GrSSO7j8nvdeHfwyXadBlaer9vIIbVnMHIal02p63S yowjL4wta0GDTHwMhyqa3fDnfZMZJc3SXllkdzD2rbKtxX8QHqU7aHWiL8iFVSYDEexp Y5TBwOxhymRo4xijghBmEvLxS1Ut7eQnIb0/QbJ1nubo+kg2T6n0+ssFpPowyf1NqBeP fymykYwYYMll6MN3tm4j9V3CTS/arPS7Y/NBlRT+dXecnnp+MkGFxJWQuL12PIT84yOl T84piIPgK4V3IDM6TMYMBjo1XXaSjReUCGT/8bUwsNN1EcampT+IhcGoljfYGcQA7MWU BfZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Nw1XuRphVhmebMWySqSgscevY/3iUqmrlDyrnRFrHKA=; b=dmqk5E/pV2DYGh5hnsWz7R7S1vyNqMOpQWLcLISL5NtCSzU+hJL1KwyhMHWOy94ion tPPSIbm6925mTFC4bqeM5CFjGoz7Q5iwj9rBjOTOxDpXCqDSHC6evr17fW86ETbZwN3H 5SOCLpnzS8YigvUu03YY8MLCm+FMQQka+9wTfKQmlky/W1A35A33PJGUsoPYtNHQ36oL GGRGVQKVJDnRdIQfpGzKAoyJmlvinlPpgrXL3YlSiLEfEo9uUPIX93Wo65TMcZ9demjY 84vW2ub8XaQggrGQb1DICcOLljqs5oT5BjEredltt2TTaU/AKLKsihSQRO1U29z/AaUZ XlDg== X-Gm-Message-State: AOAM530rX7A2vB6+Xn/ykSxtQwDikK7ZPmv7dCSdmgtimfqWqx7CBz+e L3lr1QfUgWzyq2IBhVgXmAy6wQ== X-Received: by 2002:a05:6a00:aca:b029:392:9c79:3a39 with SMTP id c10-20020a056a000acab02903929c793a39mr5815686pfl.57.1631238006377; Thu, 09 Sep 2021 18:40:06 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id y13sm3326392pfb.115.2021.09.09.18.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 18:40:05 -0700 (PDT) Date: Fri, 10 Sep 2021 01:40:01 +0000 From: Sean Christopherson To: Marc Orr Cc: Peter Gonda , kvm list , Paolo Bonzini , David Rientjes , "Dr . David Alan Gilbert" , Brijesh Singh , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3 V7] KVM, SEV: Add support for SEV intra host migration Message-ID: References: <20210902181751.252227-1-pgonda@google.com> <20210902181751.252227-2-pgonda@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021, Marc Orr wrote: > > > +int svm_vm_migrate_from(struct kvm *kvm, unsigned int source_fd) > > > +{ > > > + struct kvm_sev_info *dst_sev = &to_kvm_svm(kvm)->sev_info; > > > + struct file *source_kvm_file; > > > + struct kvm *source_kvm; > > > + int ret; > > > + > > > + ret = svm_sev_lock_for_migration(kvm); > > > + if (ret) > > > + return ret; > > > + > > > + if (!sev_guest(kvm) || sev_es_guest(kvm)) { > > > + ret = -EINVAL; > > > + pr_warn_ratelimited("VM must be SEV enabled to migrate to.\n"); > > > > Linux generally doesn't log user errors to dmesg. They can be helpful during > > development, but aren't actionable and thus are of limited use in production. > > Ha. I had suggested adding the logs when I reviewed these patches > (maybe before Peter posted them publicly). My rationale is that if I'm > looking at a crash in production, and all I have is a stack trace and > the error code, then I can narrow the failure down to this function, > but once the function starts returning the same error code in multiple > places now it's non-trivial for me to deduce exactly which condition > caused the crash. Having these logs makes it trivial. However, if this > is not the preferred Linux style then so be it. I don't necessarily disagree, but none of these errors conditions should so much as sniff production. E.g. if userspace invokes this on a !KVM fd or on a non-SEV source, or before guest_state_protected=true, then userspace has bigger problems. Ditto if the dest isn't actual KVM VM or doesn't meet whatever SEV-enabled/disabled criteria we end up with. The mismatch in online_vcpus is the only one where I could reasonablly see a bug escaping to production, e.g. due to an orchestration layer mixup. For all of these conditions, userspace _must_ be aware of the conditions for success, and except for guest_state_protected=true, userspace has access to what state it sent into KVM, e.g. it shouldn't be difficult for userspace dump the relevant bits from the src and dst without any help from the kernel. If userspace really needs kernel help to differentiate what's up, I'd rather use more unique errors for online_cpus and guest_state_protected, e.g. -E2BIG isn't too big of a strecth for the online_cpus mismatch.