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=-18.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 81600C433F5 for ; Thu, 23 Sep 2021 14:05:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CF79610C8 for ; Thu, 23 Sep 2021 14:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241559AbhIWOH2 (ORCPT ); Thu, 23 Sep 2021 10:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21908 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241567AbhIWOHX (ORCPT ); Thu, 23 Sep 2021 10:07:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632405951; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I61BRjMeqtBhdStSHIPW3/cYSD2YUvHTtLYDBjO5ZPg=; b=EGQzi3wAjcIYzM9W2FsuXNEkBWa/hx/XyvSoGAuO02A01b6kwQDYJbQm6/Abcsxr5iGHK0 qc9VeU5Ajn8D6xfORNyV2Wux58RlqyAKp3TVqS6JPjbvK1B/QQlyJEHz9xcRIGMxq85Urc ldgOaxbYPkAnjqnff1SDWhYiDU0G6vU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-7oIQipXnNMCfIT7ZyIEFLw-1; Thu, 23 Sep 2021 10:05:50 -0400 X-MC-Unique: 7oIQipXnNMCfIT7ZyIEFLw-1 Received: by mail-wr1-f70.google.com with SMTP id f7-20020a5d50c7000000b0015e288741a4so5237516wrt.9 for ; Thu, 23 Sep 2021 07:05:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=I61BRjMeqtBhdStSHIPW3/cYSD2YUvHTtLYDBjO5ZPg=; b=ULfw3BwWBuZNX3+AXkBa6fZu6OAyf5aFxQoZAhiHVbFpd64U76cedxv0rPRGMY0JIk 6KpIlwf7OcCsQrKF1AIe7G6xHgDISTORnH0ArivLvQbdId9B8ugZat5bd9qXZniozZTZ /Yp3ap0Tv9Hn+YwHQx/67GsOnT/bl7yqVcP65jb9jCcDxbjZ7b2nn8XwK8stuIldyIzL RMyjiY5NxwqblbTou1vCIDBtH9IuR1L3+GzO2GFtKzo1DCQ04Uef9FuxTKMQM9t9WGhI WNDsofD69ECUjXWg+ne/HWfJfG4nc4C+M6ISyvfW7xF+dXWrn5cxub2C3VBXWzCMS3Dx OaLg== X-Gm-Message-State: AOAM530sBfsqx460l5zWPrvv9vPa7K+WGCufILUQhTay9LZl28oamf73 3RvIYgRhlAj7r+QcZ+ys4MflO5k4/9q2pbb5LG9lJYZ1AjjBNQHaPZ4t4zO0JQ7BjpymOR5t1Z6 o0z4rHjy9LmfQJpvimPO4UreN X-Received: by 2002:a1c:f00a:: with SMTP id a10mr4627948wmb.112.1632405949070; Thu, 23 Sep 2021 07:05:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBO+kcR3MMr9vXzqpgSTE2fqf1eRRmNCeq1QHKJ3qEXiRHRA8kfVeFeyBm7fUDExvf0mXVQQ== X-Received: by 2002:a1c:f00a:: with SMTP id a10mr4627927wmb.112.1632405948843; Thu, 23 Sep 2021 07:05:48 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id 25sm10735912wmo.9.2021.09.23.07.05.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 07:05:48 -0700 (PDT) Subject: Re: [PATCH 03/14] KVM: x86: nSVM: test eax for 4K alignment for GP errata workaround To: Maxim Levitsky , kvm@vger.kernel.org Cc: Vitaly Kuznetsov , Borislav Petkov , Bandan Das , open list , Joerg Roedel , Ingo Molnar , Wei Huang , Sean Christopherson , "open list:KERNEL SELFTEST FRAMEWORK" , "H. Peter Anvin" , Jim Mattson , Thomas Gleixner , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Shuah Khan , Wanpeng Li References: <20210914154825.104886-1-mlevitsk@redhat.com> <20210914154825.104886-4-mlevitsk@redhat.com> From: Paolo Bonzini Message-ID: <59d45b27-9191-4136-929a-a7826ac891d8@redhat.com> Date: Thu, 23 Sep 2021 16:05:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210914154825.104886-4-mlevitsk@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/09/21 17:48, Maxim Levitsky wrote: > GP SVM errata workaround made the #GP handler always emulate > the SVM instructions. > > However these instructions #GP in case the operand is not 4K aligned, > but the workaround code didn't check this and we ended up > emulating these instructions anyway. > > This is only an emulation accuracy check bug as there is no harm for > KVM to read/write unaligned vmcb images. > > Fixes: 82a11e9c6fa2 ("KVM: SVM: Add emulation support for #GP triggered by SVM instructions") > > Signed-off-by: Maxim Levitsky > --- > arch/x86/kvm/svm/svm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index b2e710a3fff6..6645542df9bd 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -2224,6 +2224,10 @@ static int gp_interception(struct kvm_vcpu *vcpu) > if (error_code) > goto reinject; > > + /* All SVM instructions expect page aligned RAX */ > + if (svm->vmcb->save.rax & ~PAGE_MASK) > + goto reinject; > + > /* Decode the instruction for usage later */ > if (x86_decode_emulated_instruction(vcpu, 0, NULL, 0) != EMULATION_OK) > goto reinject; > Queued, thanks. Paolo