From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8483CC388F9 for ; Fri, 23 Oct 2020 12:02:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AA62F2463D for ; Fri, 23 Oct 2020 12:02:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VV8g+69v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA62F2463D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AE56E6B005D; Fri, 23 Oct 2020 08:02:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A711B6B0062; Fri, 23 Oct 2020 08:02:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9364E6B0071; Fri, 23 Oct 2020 08:02:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 610E16B005D for ; Fri, 23 Oct 2020 08:02:01 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F223F2826 for ; Fri, 23 Oct 2020 12:02:00 +0000 (UTC) X-FDA: 77403051600.23.story84_06134fb27259 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id CFDBA37604 for ; Fri, 23 Oct 2020 12:02:00 +0000 (UTC) X-HE-Tag: story84_06134fb27259 X-Filterd-Recvd-Size: 5381 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Fri, 23 Oct 2020 12:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603454519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+T8I0jNVBNJFOZTug7Hno1Fe0JWTKHlCqa4g8/dHMVc=; b=VV8g+69vCT4IlKZxVXhO9HjnDixG5e44ULb/AadU1z8GOBvPHtt09DFFXZ/U3XhOimY55Z iM8dZQc9o69FUKUuiWjnNF5SUL8ZCnd2rznfSj1PG1JbLRIr0KxfKarqYGfpB02/XcHvPf P9fiE0Zf+M6/LgDg+JKoao5yoaUzkYk= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-hKwTg2bJPveAajBGmr5vVw-1; Fri, 23 Oct 2020 08:01:57 -0400 X-MC-Unique: hKwTg2bJPveAajBGmr5vVw-1 Received: by mail-ed1-f72.google.com with SMTP id n16so460441edw.19 for ; Fri, 23 Oct 2020 05:01:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=+T8I0jNVBNJFOZTug7Hno1Fe0JWTKHlCqa4g8/dHMVc=; b=t9Oj7GIQGGTl07K+biOwehTFXaZyQmsqejZO0ya5EnutX1MyXadsWNMxFaGXr7XSkV rh2XJCL+9hE/VlakpGt4hzabwl70lWpktwsLMv8DmuWg2U8l/6/v/3rVlx51YY5wvF2X Kz7yK8ZqkLuRgq7irnEj0EB3ktF8ygnnVQs5ZcUb5uUDQKEhCPa3KU0V4J9HAJVfGPob YdHfFcEtmvv8FasDHmnlsM62jqEWCZQNQwapecMbrGGxgmv9ihOqzhQwR3BVwQj/yANY 8yQAxDRT/xHlrupoO9RAQ+OZT0Elnms1s1/g7MCN/QfFGbDFdro5PMFYkK9ksyRoR3hG D64g== X-Gm-Message-State: AOAM5337TfZa5jZZYUP6c0Egotw374BDDnI0JlSjjjhmw0hwjhpVa3Fw DB/VRj8BOpuY0oXG8odR2oZ5w01MwsTQr3+dq6lkXE+feKqUlYtXch5z9RzOi6ANTodHV6lrM36 Uhsw13f/XdyY= X-Received: by 2002:a17:906:51d0:: with SMTP id v16mr1613517ejk.493.1603454515438; Fri, 23 Oct 2020 05:01:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWj/IH2qG1/G46kgLoOFSkW0cPWu+PRxOBTYjbHxfBibpdohWghdzXq1cXPRl/OHFLo79U9g== X-Received: by 2002:a17:906:51d0:: with SMTP id v16mr1613476ejk.493.1603454515155; Fri, 23 Oct 2020 05:01:55 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id k25sm723342ejz.93.2020.10.23.05.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 05:01:54 -0700 (PDT) From: Vitaly Kuznetsov To: "Kirill A. Shutemov" Cc: David Rientjes , Andrea Arcangeli , Kees Cook , Will Drewry , "Edgecombe\, Rick P" , "Kleen\, Andi" , Liran Alon , Mike Rapoport , x86@kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Paolo Bonzini , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel Subject: Re: [RFCv2 00/16] KVM protected memory extension In-Reply-To: <20201023113517.j543e77hmqenjvgw@box> References: <20201020061859.18385-1-kirill.shutemov@linux.intel.com> <87ft6949x8.fsf@vitty.brq.redhat.com> <20201020134924.2i4z4kp6bkiheqws@box> <87eelr4ox3.fsf@vitty.brq.redhat.com> <20201023113517.j543e77hmqenjvgw@box> Date: Fri, 23 Oct 2020 14:01:53 +0200 Message-ID: <87sga52lse.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: "Kirill A. Shutemov" writes: > On Wed, Oct 21, 2020 at 04:46:48PM +0200, Vitaly Kuznetsov wrote: >> "Kirill A. Shutemov" writes: >> >> > Maybe it would be cleaner to handle reboot in userspace? If we got the VM >> > rebooted, just reconstruct it from scratch as if it would be new boot. >> >> We are definitely not trying to protect against malicious KVM so maybe >> we can do the cleanup there (when protection was enabled) so we can >> unprotect everything without risk of a leak? > > Do you have any particular codepath in mind? I didn't find anything > suitable so far. I didn't put much thought in it but e.g. on x86, what if we put this to kvm_vcpu_reset() under 'if (kvm_vcpu_is_bsp())' condition? The main problem I see is that we can't clean up *all* memory, e.g. firmware related stuff should stay intact and this contraducts your KVM_HC_ENABLE_MEM_PROTECTED which protects everything. We can, probably, get rid of it leaving KVM_HC_MEM_SHARE/KVM_HC_MEM_UNSHARE only shifting responsibility to define what can be cleaned up on the guest kernel (stating in the doc that all protected memory will get whiped out on reboot). -- Vitaly