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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 954D6C433E2 for ; Fri, 28 Aug 2020 12:12:35 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A6E92086A for ; Fri, 28 Aug 2020 12:12:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A6E92086A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4106C88603; Fri, 28 Aug 2020 12:12:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4JmKfZ9jJjAw; Fri, 28 Aug 2020 12:12:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id B3421885B5; Fri, 28 Aug 2020 12:12:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 964CEC07FF; Fri, 28 Aug 2020 12:12:34 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 812F9C0051 for ; Fri, 28 Aug 2020 12:12:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 70720885E3 for ; Fri, 28 Aug 2020 12:12:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oNRdPbPj-vh7 for ; Fri, 28 Aug 2020 12:12:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by hemlock.osuosl.org (Postfix) with ESMTPS id 3CB0C885B5 for ; Fri, 28 Aug 2020 12:12:32 +0000 (UTC) Received: by theia.8bytes.org (Postfix, from userid 1000) id 45AC82E1; Fri, 28 Aug 2020 14:12:29 +0200 (CEST) Date: Fri, 28 Aug 2020 14:12:26 +0200 From: Joerg Roedel To: Arvind Sankar Subject: Re: [PATCH v6 13/76] x86/boot/compressed/64: Add IDT Infrastructure Message-ID: <20200828121226.GC13881@8bytes.org> References: <20200824085511.7553-1-joro@8bytes.org> <20200824085511.7553-14-joro@8bytes.org> <20200827152657.GA669574@rani.riverdale.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200827152657.GA669574@rani.riverdale.lan> Cc: Juergen Gross , Tom Lendacky , Dave Hansen , Mike Stunes , Kees Cook , kvm@vger.kernel.org, Peter Zijlstra , Cfir Cohen , x86@kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , virtualization@lists.linux-foundation.org, Martin Radev , Joerg Roedel , Masami Hiramatsu , Andy Lutomirski , hpa@zytor.com, Erdem Aktas , David Rientjes , Dan Williams , Jiri Slaby X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" SGkgQXJ2aW5kLAoKT24gVGh1LCBBdWcgMjcsIDIwMjAgYXQgMTE6MjY6NTdBTSAtMDQwMCwgQXJ2 aW5kIFNhbmthciB3cm90ZToKPiBPbiBNb24sIEF1ZyAyNCwgMjAyMCBhdCAxMDo1NDowOEFNICsw MjAwLCBKb2VyZyBSb2VkZWwgd3JvdGU6Cj4gPiArCXB1c2hxCSVyc2kKPiA+ICsJY2FsbAlsb2Fk X3N0YWdlMV9pZHQKPiA+ICsJcG9wcQklcnNpCj4gPiArCj4gCj4gRG8gd2UgbmVlZCB0aGUgZnVu Y3Rpb25zIGxhdGVyIGluIHRoZSBzZXJpZXMgb3IgY291bGQgdGhpcyBqdXN0IHVzZSBsaWR0Cj4g ZGlyZWN0bHk/CgpUaGUgZnVuY3Rpb24gYWxzbyBzZXRzIHVwIHRoZSBhY3R1YWwgSURUIGVudHJp ZXMgaW4gdGhlIHRhYmxlIGJlZm9yZQpkb2luZyB0aGUgbGlkdCwgc28gdGhpcyBuZWVkcyB0byBi ZSBhIGNhbGwgdG8gYSBDIGZ1bmN0aW9uLiBTZXR0aW5nIHVwCklEVCBlbnRyaWVzIGluIGFzc2Vt Ymx5IGRvZXMgbm90IHJlc3VsdCBpbiByZWFkYWJsZSBjb2RlLgoKPiBJcyB0aGVyZSBhbnkgcmlz ayBvZiBleGNlcHRpb25zIGdldHRpbmcgdHJpZ2dlcmVkIGR1cmluZyB0aGUgbW92ZSBvZiB0aGUK PiBjb21wcmVzc2VkIGtlcm5lbCwgYmVmb3JlIHRoZSBzdGFnZTIgcmVsb2FkPwoKTm8sIHRoYXQg d291bGQgYmUgYSBidWcgaW4gZWl0aGVyIHRoZSBVRUZJIEJJT1Mgb3IgaW4gdGhlIGJvb3QgY29k ZS4KV2hlbiB0aGUga2VybmVsIGltYWdlI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fX19fX19fX19fXwpWaXJ0dWFsaXphdGlvbiBtYWlsaW5n IGxpc3QKVmlydHVhbGl6YXRpb25AbGlzdHMubGludXgtZm91bmRhdGlvbi5vcmcKaHR0cHM6Ly9s aXN0cy5saW51eGZvdW5kYXRpb24ub3JnL21haWxtYW4vbGlzdGluZm8vdmlydHVhbGl6YXRpb24= 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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 57DE5C433E2 for ; Fri, 28 Aug 2020 12:12:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A65B2086A for ; Fri, 28 Aug 2020 12:12:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729255AbgH1MMo (ORCPT ); Fri, 28 Aug 2020 08:12:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729123AbgH1MMd (ORCPT ); Fri, 28 Aug 2020 08:12:33 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 212F6C061264; Fri, 28 Aug 2020 05:12:31 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 45AC82E1; Fri, 28 Aug 2020 14:12:29 +0200 (CEST) Date: Fri, 28 Aug 2020 14:12:26 +0200 From: Joerg Roedel To: Arvind Sankar 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: <20200828121226.GC13881@8bytes.org> References: <20200824085511.7553-1-joro@8bytes.org> <20200824085511.7553-14-joro@8bytes.org> <20200827152657.GA669574@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200827152657.GA669574@rani.riverdale.lan> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Arvind, On Thu, Aug 27, 2020 at 11:26:57AM -0400, Arvind Sankar wrote: > On Mon, Aug 24, 2020 at 10:54:08AM +0200, Joerg Roedel wrote: > > + pushq %rsi > > + call load_stage1_idt > > + popq %rsi > > + > > Do we need the functions later in the series or could this just use lidt > directly? The function also sets up the actual IDT entries in the table before doing the lidt, so this needs to be a call to a C function. Setting up IDT entries in assembly does not result in readable code. > Is there any risk of exceptions getting triggered during the move of the > compressed kernel, before the stage2 reload? No, that would be a bug in either the UEFI BIOS or in the boot code. When the kernel image is moved to the end of the decompression buffer it still runs on the EFI page-table. With the changes in this patch-set there will be page-faults when the kernel is actually decompressed. But that happens after the stage2-idt is loaded. > > +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). You are right, I will fix that, thanks. Regards, Joerg