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=-4.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 4F681C2B9F4 for ; Sat, 19 Jun 2021 09:18:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24F746120A for ; Sat, 19 Jun 2021 09:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232164AbhFSJUX (ORCPT ); Sat, 19 Jun 2021 05:20:23 -0400 Received: from forward103p.mail.yandex.net ([77.88.28.106]:36823 "EHLO forward103p.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230318AbhFSJUW (ORCPT ); Sat, 19 Jun 2021 05:20:22 -0400 Received: from myt5-95f184467838.qloud-c.yandex.net (myt5-95f184467838.qloud-c.yandex.net [IPv6:2a02:6b8:c12:5981:0:640:95f1:8446]) by forward103p.mail.yandex.net (Yandex) with ESMTP id C439118C05A7; Sat, 19 Jun 2021 12:18:10 +0300 (MSK) Received: from myt6-9bdf92ffd111.qloud-c.yandex.net (myt6-9bdf92ffd111.qloud-c.yandex.net [2a02:6b8:c12:468a:0:640:9bdf:92ff]) by myt5-95f184467838.qloud-c.yandex.net (mxback/Yandex) with ESMTP id 4OZBN6xDsw-IAHilqQF; Sat, 19 Jun 2021 12:18:10 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1624094290; bh=G8ihFkoPxaj4xqRTQyEdHkcn0usFLQ2PC4LP8q9g2QY=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID:Cc; b=l7Cg9MX+JluGyoZxldlKcMhCavlipx4lH3rUFN59jKy9TnsnTMIpRypuRZmfVP2Y2 dhMALT/RHDvnmGlnq9zVyZ2S7ZS1LSazNLsLUxn4/jcnrb1tqJgGml0i29oZeoMaAX aujVqB0LkEpwpd0d4WVTDw+S1mRFVFpbpnFOO5rQ= Authentication-Results: myt5-95f184467838.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by myt6-9bdf92ffd111.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id Xb75OwHdKq-IA38bIdR; Sat, 19 Jun 2021 12:18:10 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Subject: Re: guest/host mem out of sync on core2duo? To: Sean Christopherson Cc: Jim Mattson , kvm list References: <73f1f90e-f952-45a4-184e-1aafb3e4a8fd@yandex.ru> <23b00d8a-1732-0b0b-cd8d-e802f7aca87c@yandex.ru> <4834cc76-72d5-4d23-7a56-63e455683db5@yandex.ru> From: stsp Message-ID: Date: Sat, 19 Jun 2021 12:18:10 +0300 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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 19.06.2021 03:54, Sean Christopherson пишет: > On Sat, Jun 19, 2021, stsp wrote: >> 19.06.2021 01:32, Sean Christopherson пишет: >>> Argh! Check out this gem: >>> >>> /* >>> * Fix the "Accessed" bit in AR field of segment registers for older >>> * qemu binaries. >>> * IA32 arch specifies that at the time of processor reset the >>> * "Accessed" bit in the AR field of segment registers is 1. And qemu >>> * is setting it to 0 in the userland code. This causes invalid guest >>> * state vmexit when "unrestricted guest" mode is turned on. >>> * Fix for this setup issue in cpu_reset is being pushed in the qemu >>> * tree. Newer qemu binaries with that qemu fix would not need this >>> * kvm hack. >>> */ >>> if (is_unrestricted_guest(vcpu) && (seg != VCPU_SREG_LDTR)) >>> var->type |= 0x1; /* Accessed */ >>> >>> >>> KVM fixes up segs when unrestricted guest is enabled, but otherwise leaves 'em >>> be, presumably because it has the emulator to fall back on for invalid state. >>> Guess what's missing in the invalid state check... >>> >>> I think this should do it: >> Until when will it run on an emulator in this case? Will it be too slow >> without a slightest hint to the user? > KVM would emulate until the invalid state went away, i.e. until the offending > register was loaded with a new segment that set the Accessed bit. Such condition will happen pretty quickly if the emulator sets the accessed bit also in LDT. Does it do that?