Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4659880rwb; Mon, 31 Jul 2023 10:06:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlHHi1zpcCFt5Xq7yH+GhZ3KxpxW1IbN1Cz4UO3j7uj/348Aq7PStoMX3EeQ0fsk/yU0tBH5 X-Received: by 2002:aa7:d452:0:b0:522:5855:ee78 with SMTP id q18-20020aa7d452000000b005225855ee78mr439839edr.32.1690823211739; Mon, 31 Jul 2023 10:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690823211; cv=none; d=google.com; s=arc-20160816; b=0ArRCzEj0U6KE1EW4LDrnxHsWMu8XFm+iLt3+MExNMnfgroyABWu5oBILt/Ab+PzxY qUSqyYsQseS5FUMSdeluzYgX3Kt2JXMu/BTQ8XF1TcabGHLB/PBMilbk1yIgmskC/nL/ qJFFIGZR0GnitMLQVo6WqL7bJ+3qyvf8XcCz9/RKuN4b3jk8qn1yC58VchI7v21/D1Se ZcTUcnbPbiZHj5ZcXpVUz6qdsKsQ4XTGIjeX2fJKEIqEqv29jb/ExNZG4cbJsCsj4gWR QkI2c9TdgQZWuY1cRP2kGnIP2vcKFEhwC4VQaaZqreWpQjZumMUOj2htBz+ZfK0Er69p QpTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ObUdgROJ4Fh6eGJrzpfR0YhkAzW7v0vw5c8AAWfwu6Y=; fh=uUGGSiOAgrKV/NbVjKPhKCaPjRkHYPjW2uA1KEpqa9g=; b=Jrssz6H71wbXpNyO882bnos4tDH7XaFGDNaxAa0utYE+o3H2lFqM9ov4lZv10BcyHf uPCYXMWud+Qb69vVU94Z7M9NHl6UzcuxcaJKIWsDPJF0dqaeFZapu2Ijx66twaxMpK3m 6jaIXh8G9wkdX5prKJed+l9P5vB/EpYiX24NZz+VMlet3fQ/4JU99V0lrhilc+1Ml5Kn WvaAxGMGxwOkj1+L/8EEd66VyX39SkyNAz+XJ66zTl2jRZTQBuoXh+Sq72n6sCYok2Zq IH5u2ZvK1iPvXqNmVM+Um0hv6cvZp7j0/6JbgyJVN6SZAGMbLjxYwic34M82ZYOVaW+u POKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Tk9LoTMT; 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 w20-20020aa7dcd4000000b0052221a15156si6567387edu.490.2023.07.31.10.06.26; Mon, 31 Jul 2023 10:06:51 -0700 (PDT) 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=20221208 header.b=Tk9LoTMT; 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 S230483AbjGaOaI (ORCPT + 99 others); Mon, 31 Jul 2023 10:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjGaOaG (ORCPT ); Mon, 31 Jul 2023 10:30:06 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BD28B6 for ; Mon, 31 Jul 2023 07:30:03 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-563fbc76454so4749850a12.2 for ; Mon, 31 Jul 2023 07:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690813802; x=1691418602; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ObUdgROJ4Fh6eGJrzpfR0YhkAzW7v0vw5c8AAWfwu6Y=; b=Tk9LoTMTTsEQqNvFWItA11F7gfp/gOQ/YnVlWInA1K44dlehN3cr8tbgER2TDsioQD M8EKZjZr+uxZAvdq1pAthJlrk/hQVImPC0csEHGHRru6EtYPWYFaQ1dK9ZYypfOlkYZM 7OIjHkZVMJra3SF3JYr8YPdSWXFrA8YESyjxZmccUc+UwE9tzenDvdDMhSQdogJ02/9V CODm8eN5WRLPtikUqG1VqppGe4N7ikOXJ7q/qqEsdshtoH2o29FkfUssxpWVO2u68lNC MRbdwHNMeLCe6r6iXAovuJbi9j/lZYb8wTzl0/MUSRwZ40jvN1IAyn8Za88mB4OVqXi4 rKsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690813802; x=1691418602; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ObUdgROJ4Fh6eGJrzpfR0YhkAzW7v0vw5c8AAWfwu6Y=; b=kRGKtt2van4wre+dS0sSH9d28vsEwutfzy0P73Oa4i/4cYeXRJgXLDtbcfXupcFT+c 7GlCfdNQbHEyIEuYAdO+T8OombS+WrYGDtzCf/6JksA9BsJb5d+tHP7pFad4n56YK9/B RBvcLZKrTi2uW8u98Zh4zBgH9ieCpr6pUBdSWaCkGqQpHMClq/owc6qzTHLwC6LzbfSq QVnNWjpQXB9uRdV3dcaZ1pQ01/tF8bw+AqSExu8Rn7ZxakAabEMo9VybtI4Se9dlRpxa GIPgYGB1KMXR7XdP9ZfAQvLi9bKcYgrbDzQch2bVkoP2k+NN0bkMT27e9LNH9nE/y8Qr fJiA== X-Gm-Message-State: ABy/qLYHv1sE33wybDeb0++n0wgW6fnhpRpLtGR6ElfdKkRfknTSDsO4 EofK4A4F+st+IsUhzvP5JSokV2Mb030= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:ce84:b0:1b8:2cee:946b with SMTP id f4-20020a170902ce8400b001b82cee946bmr43357plg.11.1690813802190; Mon, 31 Jul 2023 07:30:02 -0700 (PDT) Date: Mon, 31 Jul 2023 07:30:00 -0700 In-Reply-To: <8eb933fd-2cf3-d7a9-32fe-2a1d82eac42a@mail.ustc.edu.cn> Mime-Version: 1.0 References: <8eb933fd-2cf3-d7a9-32fe-2a1d82eac42a@mail.ustc.edu.cn> Message-ID: Subject: Re: [Question] int3 instruction generates a #UD in SEV VM From: Sean Christopherson To: wuzongyong Cc: linux-kernel@vger.kernel.org, thomas.lendacky@amd.com, kvm@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Sat, Jul 29, 2023, wuzongyong wrote: > Hi, > I am writing a firmware in Rust to support SEV based on project td-shim[1]. > But when I create a SEV VM (just SEV, no SEV-ES and no SEV-SNP) with the firmware, > the linux kernel crashed because the int3 instruction in int3_selftest() cause a > #UD. ... > BTW, if a create a normal VM without SEV by qemu & OVMF, the int3 instruction always generates a > #BP. > So I am confused now about the behaviour of int3 instruction, could anyone help to explain the behaviour? > Any suggestion is appreciated! Have you tried my suggestions from the other thread[*]? : > > I'm curious how this happend. I cannot find any condition that would : > > cause the int3 instruction generate a #UD according to the AMD's spec. : : One possibility is that the value from memory that gets executed diverges from the : value that is read out be the #UD handler, e.g. due to patching (doesn't seem to : be the case in this test), stale cache/tlb entries, etc. : : > > BTW, it worked nomarlly with qemu and ovmf. : > : > Does this happen every time you boot the guest with your firmware? What : > processor are you running on? : : And have you ruled out KVM as the culprit? I.e. verified that KVM is NOT injecting : a #UD. That obviously shouldn't happen, but it should be easy to check via KVM : tracepoints. [*] https://lore.kernel.org/all/ZMFd5kkehlkIfnBA@google.com