Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6403567ybi; Wed, 31 Jul 2019 13:48:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuv2NtB3SZn5wfkh0UQxNq3/RFHtr528xJAvqXBbBYmJl4dx39zOwL7S4g/67VbcWitbcS X-Received: by 2002:a63:6947:: with SMTP id e68mr79846789pgc.60.1564606097805; Wed, 31 Jul 2019 13:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564606097; cv=none; d=google.com; s=arc-20160816; b=iTC9YgzK8XtZ2qSyCXV+xP+D718WxnjdTozh5Ldm+ab9n6g+zAsJGyVsGqM+rKmyEw cs+uhLFAJXAN8nSGdoln2DmaI3udZvvsbKXXBw7+zL7fPhaZfZEF18sxSBKFIx2cfkPy sEQrUqmZC6TPO9Zh7EczykYYF2P8/nnOeg0z5pfTtxwiOV/fmtiL7M/5H87AYlD1oB4T urXDG59g7Rs9WJz28dN1DdMXoTbkTT/SaVa8T9VgBriHqCzW0+S08mpAGOEc/e6r1WJ2 3K6GISaJ5flO5gDDkNHi0HJHD04wNt3bCQ+PdKwWcnmMda2N/4XDuVIRYL3EDrIEgfE4 w3ig== 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=dBGsm49OysEg7bHxsXfAQevchwfTyjC8ZOrR2juUMrM=; b=zs9RI7OScsQdKfqQmoPxVAYFbAsMt2fXrFI+4hK+89zEjX+pyD5o8dfCG6LUqMKSEB BH6tEJcSCgTcH3ab4M3orO/Q7B7J71WJwN3mnLMRfE/BkVaNbtyWIhyzAjJ9wdiyipIA ERnNNOSmxqmNzfdaHYqzPKbt5h7r9rIPH5eklDZD6BzlinDoPqnmvlYDUwUOxPa+8UXz RLDGkALM4WHH7PQyh923kW5VkGs0IUu7oqE3qTo4zK0k6JW6VvfzouUk3VXqpG+GqJ8l yhZ8Vx5dJuLB5gswJPvjVwtA6gzgddb17DwyamDFQ2TiOBbnpd6owajOJpLREwBvIgnz eaJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Q2Q5ZZvL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id g2si38308921pfq.160.2019.07.31.13.48.02; Wed, 31 Jul 2019 13:48:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Q2Q5ZZvL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730551AbfGaU2F (ORCPT + 99 others); Wed, 31 Jul 2019 16:28:05 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:45645 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729730AbfGaU2F (ORCPT ); Wed, 31 Jul 2019 16:28:05 -0400 Received: by mail-io1-f67.google.com with SMTP id g20so139215987ioc.12 for ; Wed, 31 Jul 2019 13:28:04 -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=dBGsm49OysEg7bHxsXfAQevchwfTyjC8ZOrR2juUMrM=; b=Q2Q5ZZvLyygWDWivclFZ/bbeT+uEMirhfkYAS8VsgPhwm33/Jc50fxvztwqBGotkl4 Z77nFFONeALg1wxjQFQEPl5UoFIbBWWFs4S9nWN1EOgNVML9wAHPIIZQibmOIIzwDJz3 if2AqAe6gOov1+C6pHUgExQbnR6eZzQ3t9F1GhfgnVBios2EmHYkB3loA3VHMkVMcBYK db7fMEI7Srk5UcuHSJku7GmxCP4WnpXaqwUJfvXX2eOWE7En4qRQS569NYYC20Z5nscq qV+0lUKrc8OxaEadG5SqiqKehkqy837x0fj+4KGHGek8q/RibYkZ32XYlvloXV18PUvY 6Rfw== 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=dBGsm49OysEg7bHxsXfAQevchwfTyjC8ZOrR2juUMrM=; b=iv8H36eDQdkii+9fZMHMiuaCxdAA8joE7ExxOMOHSlMBiF7KPfFMlOjIaqjiDru+Mk rXG3CI5z1957TCFqpm9Hzaa88II0z71Oe/28l+yrM7xFbVXMyCc5Pb8lk41/1z7HVs/b VsUnbP/TQ4WY2/lk21gXLmt/9MT/lTDhgg9Kk1iofnEgo7fhofqzWP8dlhbmslEj8plX 5s3Ncam5cnHChyZxWHw73MrXPAoOPIA2mIzcI1rIASiZtBuubChXS1Ph8QimLPErf1TS ndO/WkEVaM0YuPyC8k/37/bNyAv4fzJ9cTl8k6W4+iudP3d1DyIuUG6i4ucPX8eWXGVk RWqA== X-Gm-Message-State: APjAAAUKwWk/quQghznMElewQ6msEKWsNQv9643GGkspd1ScQpozZPWX 1KhUYAt5Kli5jq/kF9XRSPJ6Ka5x0oHJCyUMrxQV/w== X-Received: by 2002:a6b:6310:: with SMTP id p16mr241134iog.118.1564604884032; Wed, 31 Jul 2019 13:28:04 -0700 (PDT) MIME-Version: 1.0 References: <20190620110240.25799-1-vkuznets@redhat.com> <20190620110240.25799-4-vkuznets@redhat.com> <87ftmm71p3.fsf@vitty.brq.redhat.com> <36a9f411-f90c-3ffa-9ee3-6ebee13a763f@redhat.com> In-Reply-To: <36a9f411-f90c-3ffa-9ee3-6ebee13a763f@redhat.com> From: Jim Mattson Date: Wed, 31 Jul 2019 13:27:53 -0700 Message-ID: Subject: Re: [PATCH RFC 3/5] x86: KVM: svm: clear interrupt shadow on all paths in skip_emulated_instruction() To: Paolo Bonzini Cc: Vitaly Kuznetsov , kvm list , LKML , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Joerg Roedel 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, Jul 31, 2019 at 9:37 AM Paolo Bonzini wrote: > > On 31/07/19 15:50, Vitaly Kuznetsov wrote: > > Jim Mattson writes: > > > >> On Thu, Jun 20, 2019 at 4:02 AM Vitaly Kuznetsov wrote: > >>> > >>> Regardless of the way how we skip instruction, interrupt shadow needs to be > >>> cleared. > >> > >> This change is definitely an improvement, but the existing code seems > >> to assume that we never call skip_emulated_instruction on a > >> POP-SS/MOV-to-SS/STI. Is that enforced anywhere? > > > > (before I send v1 of the series) I looked at the current code and I > > don't think it is enforced, however, VMX version does the same and > > honestly I can't think of a situation when we would be doing 'skip' for > > such an instruction.... and there's nothing we can easily enforce from > > skip_emulated_instruction() as we have no idea what the instruction > > is... Can't we still coerce kvm into emulating any instruction by leveraging a stale ITLB entry? The 'emulator' kvm-unit-test did this before the KVM forced emulation prefix was introduced, but I haven't checked to see if the original (admittedly fragile) approach still works. Also, for POP-SS, you could always force emulation by mapping the %rsp address beyond guest physical memory. The hypervisor would then have to emulate the instruction to provide bus-error semantics. > I agree, I think a comment is worthwhile but we can live with the > limitation. I think we can live with the limitation, but I'd really prefer to see a KVM exit with KVM_INTERNAL_ERROR_EMULATION for an instruction that kvm doesn't emulate properly. That seems better than just a comment that the virtual CPU doesn't behave as architected. (I realize that I am probably in the minority here.)