Received: by 10.223.185.116 with SMTP id b49csp3024081wrg; Mon, 5 Mar 2018 12:40:33 -0800 (PST) X-Google-Smtp-Source: AG47ELuspRH0+qF3v3EzWxdDxrKPsOfYslw185/8M5d0p6w0LcQwWOthGn88GybzecWhW/HDiznS X-Received: by 2002:a17:902:bb89:: with SMTP id m9-v6mr14273513pls.423.1520282433042; Mon, 05 Mar 2018 12:40:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520282433; cv=none; d=google.com; s=arc-20160816; b=IrwdFGA/TBYZXH/+ZVVYTHHZvl74DH2DOs1MkBaoy00Nk9uQWMVJegVW2j1ZpAaUgS y2yl/n3ZrVHQFcFgt09JIP+cOJsw8NVNhaM8xNgJxZOGzeF2JOn8+JSIfQdCsOrX1o4G l8LCvIeEBIEakI3q4AqiSrLB9573sz1Gnn+yn3INHQONppzjLD+boy0oat3fHSj7tblh rqM5CHkIg5HmWKPEcHiy89Xv/aAqq+Goir9m48ieTnLxXbtkoX+RnkIZpYhuW5GFg0aV iAdiK19TsJsLqhSiBPP+hcsRR3zo5tUY+BWYoSc6FFUL6u2B3qyU3j/IlKyAQpN++oEp iHYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Qv0mZ5U5KTu2VG974MfhNhnFd2t+ZU7nh+lhR6LOf8Y=; b=ImL1qEGIPqGDJQWsVnVFqMVTBeFX0KEEkkqg8WBxS+6jhqAQzZAJgw13oveDcvgO/u FQxE58fdqHYfrzgYAr46cYfKJ9dV3vHZDSgKidar3IbzUcPCXdqi4xLZtO/FfOIPs2nv wzPlF8e10XnIV4D5oBEOFPHVF9B00EtZ2nDZRjfSTWZgV4NkyNxcyNvj4CE1kZGKmp1L a27604DIJk/ERxHafX+VcUpGTGfbnOwAO3GUyiiV9oWePRW2AeWWOAK+o64BNNT4IN+Z tkgyijJEzNX9JpjCWcDIrHcmfO9QHssjOilpBnStkX6QgPmyFMWNnpNW2ksdbeG98wUx bPmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XgLA4fP+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si10675534pfg.288.2018.03.05.12.40.18; Mon, 05 Mar 2018 12:40:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XgLA4fP+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932128AbeCEUiE (ORCPT + 99 others); Mon, 5 Mar 2018 15:38:04 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:34718 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752857AbeCEUiD (ORCPT ); Mon, 5 Mar 2018 15:38:03 -0500 Received: by mail-it0-f67.google.com with SMTP id n128so10362578ith.1 for ; Mon, 05 Mar 2018 12:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Qv0mZ5U5KTu2VG974MfhNhnFd2t+ZU7nh+lhR6LOf8Y=; b=XgLA4fP+O6yeE5H7PrCax312zXc1Yyjul9yQMtzu9jNLQVWj7PJOyoRaLBGKPUe4Wp hF1cdLxbnJ6YOASgpqXBVw5I2v9kXGtIv3GctUhyq/UNcdDscX8MapWzok7x85hpXcjn H3QADa8XA55KkcInGdaBv5DAItFp0T7AW/uOC07eaSF58guwmBrM6iyM4HBpojpzyZJN 9CzmmMhvrekxZj+zYGlDmc0KwhD3m+o65CxM6OQrHZ/rHVtjun/2FFoHR1xjqgFjw2WS jpx+1n6wjIDHNOo9KDtJIMv8XnUiEXOx6cOev6hcnaSYgYbLBJuj1eZFVV0OC8U2CXjG p4nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Qv0mZ5U5KTu2VG974MfhNhnFd2t+ZU7nh+lhR6LOf8Y=; b=k7y3F0WZGzmbaAkKbRCtj4Lm7ECcie4qy1hH3Oj7uWkouN22G3VF2wURCoEtAkP9ee pRPAiZy6swSPFoFakayARRvrnXjXuDxzhhu4KHlkjBgZ497fPC3eIv6xFgkcJ96Bhi32 pkC+Jg5R0L5j9ds23MaTSjKwriRkTC7UWUxoFH6v8YzeHj6mL0o0mkMY8lwzcPsHAl12 vsTcQBe5NfgABGA0WHjHmrNvZweWHOpvi4+d+J0Wz4x5fxuPTCKamSVazETpG1uh45xw 0i5BjMT633gGyisd63RgPXHwFN9rlrbm3gdbqcG9exZSldgMDIg/QEE4nf2JeTRE1iuw nprQ== X-Gm-Message-State: AElRT7EOzC3KeIYI4NLmNm+RNi4NS6p20LqIwHlCyX7VaN/Fvkd7I/RO 65CkHHOf8NZZgXCqofTYqDp6M+bwCjY6KF/zrg== X-Received: by 10.36.178.77 with SMTP id h13mr15628116iti.2.1520282283036; Mon, 05 Mar 2018 12:38:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.118.212 with HTTP; Mon, 5 Mar 2018 12:38:02 -0800 (PST) In-Reply-To: References: <1520245563-8444-1-git-send-email-joro@8bytes.org> <1520245563-8444-8-git-send-email-joro@8bytes.org> <20180305131231.GR16484@8bytes.org> From: Brian Gerst Date: Mon, 5 Mar 2018 15:38:02 -0500 Message-ID: Subject: Re: [PATCH 07/34] x86/entry/32: Restore segments before int registers To: Linus Torvalds Cc: Joerg Roedel , Thomas Gleixner , Ingo Molnar , Peter Anvin , "the arch/x86 maintainers" , Linux Kernel Mailing List , linux-mm , Andrew Lutomirski , Dave Hansen , Josh Poimboeuf , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , David Laight , Denys Vlasenko , Eduardo Valentin , Greg Kroah-Hartman , Will Deacon , "Liguori, Anthony" , Daniel Gruss , Hugh Dickins , Kees Cook , Andrea Arcangeli , Waiman Long , Pavel Machek , Joerg Roedel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 5, 2018 at 1:23 PM, Linus Torvalds wrote: > On Mon, Mar 5, 2018 at 5:12 AM, Joerg Roedel wrote: >> >>> The things is, we *know* that we will restore two segment registers with the >>> user cr3 already loaded: CS and SS get restored with the final iret. >> >> Yeah, I know, but the iret-exception path is fine because it will >> deliver a SIGILL and doesn't return to the faulting iret. > > That's not so much my worry, as just getting %cr3 wrong. The fact is, > we still take the exception, and we still have to handle it, and that > still needs to get the user<->kernel cr3 right. > > So then the whole "restore segments early" must be wrong, because > *that* path must get it all right too, no? > > And it appears that the code *does* get it right, and you can just > avoid this patch entirely? > >> The iret-exception case is tested by the ldt_gdt selftest (the >> do_multicpu_tests subtest). But I didn't actually tested single-stepping >> through sysenter yet. I just re-ran the same tests I did with v2 on this >> patch-set. > > Ok. Maybe we should have a test for the "take DB on first instruction > of sysenter". > > Linus There already is a test: single_step_syscall.c -- Brian Gerst