Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp670394ybg; Wed, 10 Jun 2020 10:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYs/I5Bsyd5c0NegbEIHJhojgO8StNuSjJstt94PApDtHErFaNykY2I5mjWJ8oxTKQUFhp X-Received: by 2002:a17:906:f1d5:: with SMTP id gx21mr4548922ejb.416.1591810178476; Wed, 10 Jun 2020 10:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591810178; cv=none; d=google.com; s=arc-20160816; b=ozsZZh/+G9PoXDSSrSDLq+Ro8jkrorz3Q8etZDRJJZMJY4e3MmI33dWQlhj10aYqYk fz/PjfhyEgebJQkXjVKVpznbYYQ2fdJPtiVaTT8BzxUXhNoCC1ZK6DfpMRPoDzIilzjl /ohTuJ2ppTIs2Za4v7T4GZg1K9ecAQhnAdYwBmPArxu0KW+5EEDe0Oa7nE4RVvyHKg/T 3x5n6hDdrxy1qxQpkMhgkJOxZeS2jJ8xjqH9Q0/7thDJyOVjNeZ49PKjUHjzdrEY3NsC WrTR8XnQdgVQMHlFPOyyQRhvVJt5TGi7HMxNQ3MtBCjjHxx/0llc1n2HPC0gLIvbWnnr +eiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SbsE0+B0P8frLwxQJdTPZKfsaWPnfG0PYAG3BHter6I=; b=z00/TRtLArx8XKzTtWzePMvUOeRJzu5jwcUVxSZ2yrfavGz92NlNZrBwMW4gX93Gtf 8o7xX22Kp+/IlhXlstWeGCcvGzRwjqkJrYjpUNz1k6GwcrKaSAM4MNK+UbZuoHGm4OEW FJTMM1lF8bW6IIH+WpX7pce1w58FhG8KwqO9cPlfArcJeFNba23hyS2GUZj+zXbXrrO2 Io40QoR+6Q1EkytzNwuQbFuGuaqN+FPEksmHS1JHWL43oOhzr3+Y4oEu7ujJAjdapLBI 2EjO/gAI9Vm/T2B5Tz5oigPpD6o5F1mtVxSPvRhj/Psi2PUH2K8Vv6Wv6dz/kdZGzx/x nFng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nHFMyDoX; 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 m5si418979ejr.560.2020.06.10.10.29.15; Wed, 10 Jun 2020 10:29:38 -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=20161025 header.b=nHFMyDoX; 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 S1729405AbgFJRLy (ORCPT + 99 others); Wed, 10 Jun 2020 13:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728642AbgFJRLx (ORCPT ); Wed, 10 Jun 2020 13:11:53 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B6C8C03E96B for ; Wed, 10 Jun 2020 10:11:52 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id t9so3056268ioj.13 for ; Wed, 10 Jun 2020 10:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SbsE0+B0P8frLwxQJdTPZKfsaWPnfG0PYAG3BHter6I=; b=nHFMyDoX1ZRneSZnzjWlUSdmZCxhP8i2hwnyouel/90ri5jqN6XXyPfjtdeokytvZo FG7EOchl6gbjtmYsQDyxVG3SV1uVo9MHQtIoJADI3/aaBJByFTanhFJXFBWr7PIafOCu V1Kl/FEUatLNd+J6d+Sdm2KAg/h+Ud4nXqTiUhq9TdwgAtDfP8IK+m9Y/Hvtm2iVCjdQ 6iRQr1DHqBml/HeJkQZPwogYzby/SthO1fN2Go7zKjsblnSkieqhUYuknRPHqwoDTMBG B/LF0+Rt4DXknqkAU2c4GnwH9JSR0txzTcJaFg3CmwtuCe9re6xV+tqy/IsXMaH7Lu8D PREA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SbsE0+B0P8frLwxQJdTPZKfsaWPnfG0PYAG3BHter6I=; b=BUsIsRbE8x0St175cXSw230jddoymvw9CwjezDRFbHRMNlQ+Yl78uxYH8EM9X0aJ8i V8LH9om0JG8CmQmtv6hPBeDRz6NFKT8m6HT3AKkWFZ9Qb5Ky4iAnc7/LBtkY1CihoD+Z 2ZQtpoXRTON61hy9J7WIvguNB10rZLwzCYguK6cInY8KIaX9oGx+9SqODExhWYkYKZz/ sW1pioSXBw/FyfZJzjMy5WRWVSSe46YX4uRRBFwsJcjJdF9zTbe8WBKJhOhR7FlPOdAX rMc3pR2Vhqev1ZLEtx2kHMFN0KXhJ9G8zy1TqLWbOmgAhyyAnQql+SDcbUGpi5zCJ3Ka JIiQ== X-Gm-Message-State: AOAM5323245whbTNICCA4ePrC4I13O1vYLCql2iG5K6dGhPzJ+o+RQkO wYalQUubrF1HDPDR2ZrfKTLJ2vMb12KjYo4gqcrdSw== X-Received: by 2002:a02:ce56:: with SMTP id y22mr4098658jar.18.1591809110794; Wed, 10 Jun 2020 10:11:50 -0700 (PDT) MIME-Version: 1.0 References: <20200610164116.770811-1-vkuznets@redhat.com> In-Reply-To: <20200610164116.770811-1-vkuznets@redhat.com> From: Jim Mattson Date: Wed, 10 Jun 2020 10:11:38 -0700 Message-ID: Subject: Re: [PATCH] KVM: selftests: fix sync_with_host() in smm_test To: Vitaly Kuznetsov Cc: kvm list , Paolo Bonzini , Sean Christopherson , Wanpeng Li , Marcelo Bandeira Condotta , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 10, 2020 at 9:41 AM Vitaly Kuznetsov wrote: > > It was reported that older GCCs compile smm_test in a way that breaks > it completely: > > kvm_exit: reason EXIT_CPUID rip 0x4014db info 0 0 > func 7ffffffd idx 830 rax 0 rbx 0 rcx 0 rdx 0, cpuid entry not found > ... > kvm_exit: reason EXIT_MSR rip 0x40abd9 info 0 0 > kvm_msr: msr_read 487 = 0x0 (#GP) > ... > > Note, '7ffffffd' was supposed to be '80000001' as we're checking for > SVM. Dropping '-O2' from compiler flags help. Turns out, asm block in > sync_with_host() is wrong. We us 'in 0xe, %%al' instruction to sync > with the host and in 'AL' register we actually pass the parameter > (stage) but after sync 'AL' gets written to but GCC thinks the value > is still there and uses it to compute 'EAX' for 'cpuid'. That smells like VMware's hypercall madness! > smm_test can't fully use standard ucall() framework as we need to > write a very simple SMI handler there. Fix the immediate issue by > making RAX input/output operand. While on it, make sync_with_host() > static inline. > > Reported-by: Marcelo Bandeira Condotta > Signed-off-by: Vitaly Kuznetsov Reviewed-by: Jim Mattson