Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp923794pxb; Tue, 8 Feb 2022 05:40:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwV4RRyZ5KLf6fYJH9wDxGidGW7bqe1zSGSi3oDpY7LRRGhf0I6fCfqcGAFFuQRtJ9sZLMI X-Received: by 2002:a17:90b:3808:: with SMTP id mq8mr1431916pjb.225.1644327649451; Tue, 08 Feb 2022 05:40:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644327649; cv=none; d=google.com; s=arc-20160816; b=u3FkPnyDonwUgEFsjiIDLVslqyutB+7R8M++24oiMHU+WCwAH7QRVxmY8qZvHTKsiF ZNMLcTEmL4TByVbQvaULHeGB3UXgIK7wNo7i9Fm/hwHHfKqqHgDE7iq6KkHRpwNg1gky PMj+ece/oYIjd0K+ufNTwDDsk14jKxKRrdwfsRV+afwkjXRPIeZIQbomakBVf21m0MwK IiFDzwclyboSMQGcB0l5AdjJD1R0twcDzOjTSUBpxAwIaOOuhB1/aiNPCS7aJDmsmyPl UJEShv5Mzuqi4iWfYPcZX8qkWeOScHwDOs8VMSPDaSUeZFVwbf1/V6t0d88/g+sRecAj sz/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dQAmEJaTjsYYRj2/TdOMTdvz+CnRCYyBekCT/t8kf+I=; b=C71TdYFVbOQsx05VwrSktBP59CfiH9+ZUaHYIyD8aIq/mYfxzMUoL+mWKnZipvd7yG e1pjBUE7tvfKcD0ROQOPGjqXe8hbQpHFgLmnyyMqaOh/J7rYJZCLG/1eolLhvrMGMoY6 6TR4A1+wm0Z2qePkrLmXVLfwwdPJoEOryFFMymoSV7pnk8g0zg1Bo7PcEEp+e1LC523G k8XHbVMYtO3GDx0GaTEFz2mctSVxh7Im6hVmiCWeY4tuZTvwFO4mgNLKZF3tAPHKPVH7 NY7UhMoHw+pvAzUKiU84CdXqjDUASe8fIWAKeyjE+8qjAUA4oM5L7GIA2gon8qh4fJtH iHGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=sDoAX6Ob; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6si14143536plg.390.2022.02.08.05.40.35; Tue, 08 Feb 2022 05:40:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=sDoAX6Ob; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239057AbiBGTXd (ORCPT + 99 others); Mon, 7 Feb 2022 14:23:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240154AbiBGTVZ (ORCPT ); Mon, 7 Feb 2022 14:21:25 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E2CC0401E1 for ; Mon, 7 Feb 2022 11:21:24 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id on2so5473506pjb.4 for ; Mon, 07 Feb 2022 11:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dQAmEJaTjsYYRj2/TdOMTdvz+CnRCYyBekCT/t8kf+I=; b=sDoAX6Ob3ofOrHoMs08opCxUyc5qyAleP2EdPje331+PoY9+p3tHS81w/wOhERj1v0 1Y6NHxbgaGvbgf+GfnJonkDP7YDfJ7F+4UwhIwJr9YvU3XI+g6x+OAqYPgV5Kyd8LPEc 2VM2Ol0xD8wL7lCq0lEkbawbcKHzGYyegUbVYJ9sDWvQ2MfxhMVLb8G21aVb2qOXVrz2 u0tCqjBaemKygGUudLqVQY4NcLRMDUy07FR6V8y3EUjNhDHMRXQReXGQdTzNKbit5/io hwEVTkStMysseSIvXNrYRYfppmCk9nI2r7dhQnk21INNuuVRU666S9oLYoDOF5teROrm Ul1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dQAmEJaTjsYYRj2/TdOMTdvz+CnRCYyBekCT/t8kf+I=; b=DDSWhN96iIEfufp14vONc1LB7pVkHbNPOYRnMPDd5SM7q3rjjp9iPTZ23o8Bn8k8go 6rtqrF0IXiOZFLUVCSjTwgKl/9fZHJRD2FMzTOFTNCU6MRw7wY/6i2f5LA/ls1Gs7QKm YJCUmdJ+5EGhJbl09uP3i/RTtkLtFayIMT1i27isXCFoICFOfgQor0dKXjmgvMogvpOn ptps/Bek4zZHOMbWBX48fNcy8apl5eIx+bcrI1Vij3S4nH7azhGa0xfnokvIQoDKmp9X Kgl9aOWs0TRzd6Yc8jKPwaBkcMFh2Z/Q6CxcRvDh39OuPuQNENUNK9f9sZJjDo9Vf1Bj 2Jng== X-Gm-Message-State: AOAM53113cDB2HPOoOd+pP0sKLILphVP0Nmbf3kKrdyxxf0tNJ09fQsa eLhWqYN4BBAwnIu+mfdtLq28ZA== X-Received: by 2002:a17:903:11c7:: with SMTP id q7mr1135434plh.83.1644261684169; Mon, 07 Feb 2022 11:21:24 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id h14sm14265846pfh.95.2022.02.07.11.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 11:21:23 -0800 (PST) Date: Mon, 7 Feb 2022 19:21:19 +0000 From: Sean Christopherson To: Hou Wenlong Cc: kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Marcelo Tosatti , Gleb Natapov , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] KVM: x86/emulator: Defer not-present segment check in __load_segment_descriptor() Message-ID: References: <117283244eab58e94d589af58a5f2b245b8c0025.1642669684.git.houwenlong.hwl@antgroup.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <117283244eab58e94d589af58a5f2b245b8c0025.1642669684.git.houwenlong.hwl@antgroup.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022, Hou Wenlong wrote: > Per Intel's SDM on the "Instruction Set Reference", when > loading segment descriptor, not-present segment check should > be after all type and privilege checks. But the emulator checks > it first, then #NP is triggered instead of #GP if privilege fails > and segment is not present. Put not-present segment check after > type and privilege checks in __load_segment_descriptor(). For posterity, KVM doesn't support CALL GATES or TASK GATES, so the "early" #NP check for those is missing. > Fixes: 38ba30ba51a00 (KVM: x86 emulator: Emulate task switch in emulator.c) > Signed-off-by: Hou Wenlong > --- Reviewed-by: Sean Christopherson