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=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 AB0BFC433DF for ; Thu, 27 Aug 2020 15:27:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 872082087D for ; Thu, 27 Aug 2020 15:27:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rwaezHLB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726393AbgH0P1C (ORCPT ); Thu, 27 Aug 2020 11:27:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgH0P1B (ORCPT ); Thu, 27 Aug 2020 11:27:01 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B8DC061264; Thu, 27 Aug 2020 08:27:00 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id k18so4785170qtm.10; Thu, 27 Aug 2020 08:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=7UREsbmmfUl6uKDuaxhy7wo7SSoNjIwrrnq3Cb8sDVE=; b=rwaezHLBXo3AhAay1MBvcv8LFx6RGX0pQZUAqP91NiIsN5xJ99bIZpRhFZQnC8mXgZ x1mVX1lr8PvGkgQvM7aSdscLvx7BXQwAucX6azU+yG1DXfZdVCag/9aYwO27qzXnAIex Bwi1yfimf0VV4GYNzsuR7IfoQttvs0hckYkyJAVu2i7tgbTNAWYNbc4SyJAzzLvfiKko ALxulrR5llewc3WOi0rv3owL6qeLVtj3+9O37nMZqNLBupHAXmQZr2+ucCHZbm0UXYNc JfXcdA4RMo9CdOv9/bI7NRBp4IcipfzSmTR7Jmu1bVh380K3IF9Wob24gmuwHHEXtoN+ CCUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=7UREsbmmfUl6uKDuaxhy7wo7SSoNjIwrrnq3Cb8sDVE=; b=Onr6O89a79tan63JjhWPFmMm2dNnXbUCIIMBn6nMzM/bBewck427eIDKS8QCm9QQ1a 5K2g56YhXovTVi/c+GnfFVkwsEyLFW5i3PK+CyJ8a/hE6diOrG+qGZTrQFfUGZGmNROi 5UPjGbR6ENrSbQDBHOdHqQVk9Ja5T41kb+gk5NhG8pRH2PONtKPZHQZfbd/mzsNgTZyj 65e2MTsXHd8noF1izlYhEO7/Kn2qTxqcpjpJmHBTZhFxHQrUlC3lpxixrsT8aW6j6Y6F 5PuNDpGlVXqpvca9TOHA688nO/srAnI55e3oAr6FtC6uIDQcOstq9z61yTJ0u6PpzMPE pWmA== X-Gm-Message-State: AOAM531aaMJ2Wl/RyV8MsZeHkIPZmYLcpHi59DqyMfpnIVsnVxADxVRq AQrxxPMEhEDbkEX9QHwVL55PsKWlp2I= X-Google-Smtp-Source: ABdhPJznEyF0mZAogiSFgjmdI6X+tyx1xA88jTcbKW6mRF+XTymMpK8jWQDvlZ+RBBtCcslMP15KFA== X-Received: by 2002:ac8:4248:: with SMTP id r8mr18734289qtm.218.1598542019916; Thu, 27 Aug 2020 08:26:59 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id d17sm1950504qkj.96.2020.08.27.08.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2020 08:26:59 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Thu, 27 Aug 2020 11:26:57 -0400 To: Joerg Roedel Cc: x86@kernel.org, Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v6 13/76] x86/boot/compressed/64: Add IDT Infrastructure Message-ID: <20200827152657.GA669574@rani.riverdale.lan> References: <20200824085511.7553-1-joro@8bytes.org> <20200824085511.7553-14-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200824085511.7553-14-joro@8bytes.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Aug 24, 2020 at 10:54:08AM +0200, Joerg Roedel wrote: > From: Joerg Roedel > > Add code needed to setup an IDT in the early pre-decompression > boot-code. The IDT is loaded first in startup_64, which is after > EfiExitBootServices() has been called, and later reloaded when the > kernel image has been relocated to the end of the decompression area. > > This allows to setup different IDT handlers before and after the > relocation. > > Signed-off-by: Joerg Roedel > Link: https://lore.kernel.org/r/20200724160336.5435-13-joro@8bytes.org > diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S > index 9e46729cf162..260c7940f960 100644 > --- a/arch/x86/boot/compressed/head_64.S > +++ b/arch/x86/boot/compressed/head_64.S > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > #include "pgtable.h" > > /* > @@ -415,6 +416,10 @@ SYM_CODE_START(startup_64) > > .Lon_kernel_cs: > > + pushq %rsi > + call load_stage1_idt > + popq %rsi > + Do we need the functions later in the series or could this just use lidt directly? Is there any risk of exceptions getting triggered during the move of the compressed kernel, before the stage2 reload? > > +SYM_DATA_START(boot_idt_desc) > + .word boot_idt_end - boot_idt I think this should be boot_idt_end - boot_idt - 1, right? The limit value is expressed in bytes and is added to the base address to get the address of the last valid byte. A limit value of 0 results in exactly 1 valid byte. Because IDT entries are always eight bytes long, the limit should always be one less than an integral multiple of eight (that is, 8N – 1). > + .quad 0 > +SYM_DATA_END(boot_idt_desc) > + .balign 8 > +SYM_DATA_START(boot_idt) > + .rept BOOT_IDT_ENTRIES > + .quad 0 > + .quad 0 > + .endr > +SYM_DATA_END_LABEL(boot_idt, SYM_L_GLOBAL, boot_idt_end) > +