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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 5E860C54FCB for ; Mon, 27 Apr 2020 14:09:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 3598F2063A for ; Mon, 27 Apr 2020 14:09:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3598F2063A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jT4Rc-0006LP-Gh; Mon, 27 Apr 2020 14:09:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jT4Rb-0006LK-GS for xen-devel@lists.xenproject.org; Mon, 27 Apr 2020 14:09:11 +0000 X-Inumbo-ID: a9fce6d6-8890-11ea-9797-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a9fce6d6-8890-11ea-9797-12813bfff9fa; Mon, 27 Apr 2020 14:09:10 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 59E49ABB2; Mon, 27 Apr 2020 14:09:08 +0000 (UTC) Subject: Re: [PATCH] x86: refine guest_mode() To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= References: <7b62d06c-1369-2857-81c0-45e2434357f4@suse.com> <20200427095913.GN28601@Air-de-Roger> From: Jan Beulich Message-ID: <40d5c1b8-b68e-1aa8-b17e-77ba9afc6529@suse.com> Date: Mon, 27 Apr 2020 16:08:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200427095913.GN28601@Air-de-Roger> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "xen-devel@lists.xenproject.org" , Wei Liu , Andrew Cooper Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 27.04.2020 11:59, Roger Pau Monné wrote: > On Mon, Apr 27, 2020 at 10:03:05AM +0200, Jan Beulich wrote: >> --- a/xen/include/asm-x86/regs.h >> +++ b/xen/include/asm-x86/regs.h >> @@ -10,9 +10,10 @@ >> /* Frame pointer must point into current CPU stack. */ \ >> ASSERT(diff < STACK_SIZE); \ >> /* If not a guest frame, it must be a hypervisor frame. */ \ >> - ASSERT((diff == 0) || (r->cs == __HYPERVISOR_CS)); \ >> + if ( diff < PRIMARY_STACK_SIZE ) \ >> + ASSERT(!diff || ((r)->cs == __HYPERVISOR_CS)); \ > > Why not use: > > ASSERT(diff >= PRIMARY_STACK_SIZE || !diff || ((r)->cs == __HYPERVISOR_CS)); Except for the longer (without being helpful imo) string reported if the assertion triggers, I see not difference. > I'm not sure I fully understand this layout, is it possible that you > also need to account for the size of cpu_info? Depends on how paranoid we want the checking here to be, but in going further I wouldn't want this to become sub-page fine-grained if we aren't first doing e.g. what I'm mentioning in the post-commit-message remark. Jan