From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35176 invoked by alias); 4 Oct 2015 21:07:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 35164 invoked by uid 89); 4 Oct 2015 21:07:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vk0-f47.google.com Received: from mail-vk0-f47.google.com (HELO mail-vk0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 04 Oct 2015 21:07:48 +0000 Received: by vkgd64 with SMTP id d64so86134247vkg.0 for ; Sun, 04 Oct 2015 14:07:46 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.31.181.205 with SMTP id e196mr17465175vkf.128.1443992866071; Sun, 04 Oct 2015 14:07:46 -0700 (PDT) Received: by 10.103.40.68 with HTTP; Sun, 4 Oct 2015 14:07:45 -0700 (PDT) In-Reply-To: References: <2AB9494F-91EC-4CF6-945B-0CB03A583513@comcast.net> <1D91C2C8-833D-4F6D-9C57-C22D61662A83@comcast.net> Date: Sun, 04 Oct 2015 21:07:00 -0000 Message-ID: Subject: Re: [PATCH] x86 interrupt attribute From: Uros Bizjak To: "H.J. Lu" Cc: Yulia Koval , Mike Stump , GCC Patches Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-10/txt/msg00349.txt.bz2 On Sun, Oct 4, 2015 at 10:51 PM, H.J. Lu wrote: > On Sun, Oct 4, 2015 at 1:00 PM, Uros Bizjak wrote: >> On Sun, Oct 4, 2015 at 8:15 PM, H.J. Lu wrote: >> >>>> Looking a bit deeper into the code, it looks that we want to realign >>>> the stack in the interrupt handler. Let's assume that interrupt >>>> handler is calling some other function that saves SSE vector regs to >>>> the stack. According to the x86 ABI, incoming stack of the called >>>> function is assumed to be aligned to 16 bytes. But, interrupt handler >>>> violates this assumption, since the stack could be aligned to only 4 >>>> bytes for 32bit and 8 bytes for 64bit targets. Entering the called >>>> function with stack, aligned to less than 16 bytes will certainly >>>> violate ABI. >>>> >>>> So, it looks to me that we need to realign the stack in the interrupt >>>> handler unconditionally to 16bytes. In this case, we also won't need >>>> the following changes: >>>> >>> >>> Current stack alignment implementation requires at least >>> one, maybe two, scratch registers: >>> >>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67841 >>> >>> Extend it to the interrupt handler, which doesn't have any scratch >>> registers may require significant changes in backend as well as >>> register allocator. >> >> But without realignment, the handler is unusable for anything but >> simple functions. The handler will crash when called function will try >> to save vector reg to stack. >> > > We can use unaligned load and store to avoid crash. Oh, sorry, I meant "called function will crash", like: -> interrupt when %rsp = 0x...8 -> -> interrupt handler -> -> calls some function that tries to save xmm reg to stack -> crash in the called function Uros.