What does it take to run 64-bit userland software on a 32-bit kernel?












9















On Linux and Windows, I'm used to the situation that I require a 64-bit kernel to have a system with multiarch/WoW where I can run 32-bit and 64-bit software side-by-side.



And then, years ago it blew my mind when someone showed me that MacOS 10.6 Snow Leopard could run 64-bit applications with the kernel in 32-bit mode. This may be largely forgotten now because it was a one-time technology transition. With the hardware ahead of the curve in the mobile space, as far as I know this was never needed in the move to 64-bit for iOS and Android.



My question: What would it take to get the same capability in a 32-bit Linux kernel (i386 or armhf)?



I understand that this probably isn't trivial. If it was, Microsoft could have put the feature into Windows XP 32-bit. What are the general requirements though? Has there ever been a proposed patch or proof-of-concept?



In the embedded world I think this would be especially helpful, as 64-bit support can lag behind for a long time in device drivers.










share|improve this question

























  • Are you sure Snow Leopard could run 64-bit apps with a 32-bit kernel? IIRC the kernel was also updated on capable hardware to 64-bit.

    – muru
    Nov 13 '18 at 5:46






  • 5





    Never mind, you were right: superuser.com/a/340591/334516

    – muru
    Nov 13 '18 at 5:47






  • 2





    See also unix.stackexchange.com/questions/410237/… and unix.stackexchange.com/questions/134391/…

    – Gilles
    Nov 13 '18 at 21:14
















9















On Linux and Windows, I'm used to the situation that I require a 64-bit kernel to have a system with multiarch/WoW where I can run 32-bit and 64-bit software side-by-side.



And then, years ago it blew my mind when someone showed me that MacOS 10.6 Snow Leopard could run 64-bit applications with the kernel in 32-bit mode. This may be largely forgotten now because it was a one-time technology transition. With the hardware ahead of the curve in the mobile space, as far as I know this was never needed in the move to 64-bit for iOS and Android.



My question: What would it take to get the same capability in a 32-bit Linux kernel (i386 or armhf)?



I understand that this probably isn't trivial. If it was, Microsoft could have put the feature into Windows XP 32-bit. What are the general requirements though? Has there ever been a proposed patch or proof-of-concept?



In the embedded world I think this would be especially helpful, as 64-bit support can lag behind for a long time in device drivers.










share|improve this question

























  • Are you sure Snow Leopard could run 64-bit apps with a 32-bit kernel? IIRC the kernel was also updated on capable hardware to 64-bit.

    – muru
    Nov 13 '18 at 5:46






  • 5





    Never mind, you were right: superuser.com/a/340591/334516

    – muru
    Nov 13 '18 at 5:47






  • 2





    See also unix.stackexchange.com/questions/410237/… and unix.stackexchange.com/questions/134391/…

    – Gilles
    Nov 13 '18 at 21:14














9












9








9


2






On Linux and Windows, I'm used to the situation that I require a 64-bit kernel to have a system with multiarch/WoW where I can run 32-bit and 64-bit software side-by-side.



And then, years ago it blew my mind when someone showed me that MacOS 10.6 Snow Leopard could run 64-bit applications with the kernel in 32-bit mode. This may be largely forgotten now because it was a one-time technology transition. With the hardware ahead of the curve in the mobile space, as far as I know this was never needed in the move to 64-bit for iOS and Android.



My question: What would it take to get the same capability in a 32-bit Linux kernel (i386 or armhf)?



I understand that this probably isn't trivial. If it was, Microsoft could have put the feature into Windows XP 32-bit. What are the general requirements though? Has there ever been a proposed patch or proof-of-concept?



In the embedded world I think this would be especially helpful, as 64-bit support can lag behind for a long time in device drivers.










share|improve this question
















On Linux and Windows, I'm used to the situation that I require a 64-bit kernel to have a system with multiarch/WoW where I can run 32-bit and 64-bit software side-by-side.



And then, years ago it blew my mind when someone showed me that MacOS 10.6 Snow Leopard could run 64-bit applications with the kernel in 32-bit mode. This may be largely forgotten now because it was a one-time technology transition. With the hardware ahead of the curve in the mobile space, as far as I know this was never needed in the move to 64-bit for iOS and Android.



My question: What would it take to get the same capability in a 32-bit Linux kernel (i386 or armhf)?



I understand that this probably isn't trivial. If it was, Microsoft could have put the feature into Windows XP 32-bit. What are the general requirements though? Has there ever been a proposed patch or proof-of-concept?



In the embedded world I think this would be especially helpful, as 64-bit support can lag behind for a long time in device drivers.







kernel 64bit 32bit multiarch






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 17:16







jdonald

















asked Nov 13 '18 at 5:09









jdonaldjdonald

15816




15816













  • Are you sure Snow Leopard could run 64-bit apps with a 32-bit kernel? IIRC the kernel was also updated on capable hardware to 64-bit.

    – muru
    Nov 13 '18 at 5:46






  • 5





    Never mind, you were right: superuser.com/a/340591/334516

    – muru
    Nov 13 '18 at 5:47






  • 2





    See also unix.stackexchange.com/questions/410237/… and unix.stackexchange.com/questions/134391/…

    – Gilles
    Nov 13 '18 at 21:14



















  • Are you sure Snow Leopard could run 64-bit apps with a 32-bit kernel? IIRC the kernel was also updated on capable hardware to 64-bit.

    – muru
    Nov 13 '18 at 5:46






  • 5





    Never mind, you were right: superuser.com/a/340591/334516

    – muru
    Nov 13 '18 at 5:47






  • 2





    See also unix.stackexchange.com/questions/410237/… and unix.stackexchange.com/questions/134391/…

    – Gilles
    Nov 13 '18 at 21:14

















Are you sure Snow Leopard could run 64-bit apps with a 32-bit kernel? IIRC the kernel was also updated on capable hardware to 64-bit.

– muru
Nov 13 '18 at 5:46





Are you sure Snow Leopard could run 64-bit apps with a 32-bit kernel? IIRC the kernel was also updated on capable hardware to 64-bit.

– muru
Nov 13 '18 at 5:46




5




5





Never mind, you were right: superuser.com/a/340591/334516

– muru
Nov 13 '18 at 5:47





Never mind, you were right: superuser.com/a/340591/334516

– muru
Nov 13 '18 at 5:47




2




2





See also unix.stackexchange.com/questions/410237/… and unix.stackexchange.com/questions/134391/…

– Gilles
Nov 13 '18 at 21:14





See also unix.stackexchange.com/questions/410237/… and unix.stackexchange.com/questions/134391/…

– Gilles
Nov 13 '18 at 21:14










2 Answers
2






active

oldest

votes


















16














Running 64-bit applications requires some support from the kernel: the kernel needs to at least set up page tables, interrupt tables etc. as necessary to support running 64-bit code on the CPU, and it needs to save the full 64-bit context when switching between applications (and from applications to the kernel and back). Thus a purely 32-bit kernel can’t support 64-bit userspace.



However a kernel can run 32-bit code in kernel space, while supporting 64-bit code in user space. That involves handling similar to the support required to run 32-bit applications with a 64-bit kernel: basically, the kernel has to support the 64-bit interfaces the applications expect. For example, it has to provide some mechanism for 64-bit code to call into the kernel, and preserve the meaning of the parameters (in both directions).



The question then is whether it’s worth it. On the Mac, and some other systems, a case can be made since supporting 32-bit kernel code means drivers don’t all have to make the switch simultaneously. On Linux the development model is different: anything in the kernel is migrated as necessary when large changes are made, and anything outside the kernel isn’t really supported by the kernel developers. Supporting 32-bit userland with a 64-bit kernel is certainly useful and worth the effort (at least, it was when x86-64 support was added), I’m not sure there’s a case to be made for 64-bit on 32-bit...






share|improve this answer


























  • Thanks this is helpful, although now that Gilles has pointed out his related answer on unix.stackexchange I think there's more desired for completeness. From what I gather buried there in the comment stream, apparently this is still impossible on armhf due to architectural limitations while theoretically feasible for i386? Case to be made: initial motivation was Raspbian, where the foundation's roadmap is to maintain a single kernel for years to come while retaining compatibility with the Pi Zero.

    – jdonald
    Nov 14 '18 at 21:00



















3














Snow leopard was able to run 64 bits binaries in an Intel 64 bit CPU.



It was also able to boot with a 64 bit kernel when your efi was already 64 bits (my production batch of the Macbook "transition-model" pro was already such a machine).



There was no emulation involved, you just paid a smaller performance cost when booting in 32 bits mode afair.



In pure 32-bit CPUs, you won't be able to do that, as they have no idea how to interpret 64 bit code. Unless you are emulating with software, which would be to slow for those kind of traditionally underpowered embedded class of machines.






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481382%2fwhat-does-it-take-to-run-64-bit-userland-software-on-a-32-bit-kernel%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    16














    Running 64-bit applications requires some support from the kernel: the kernel needs to at least set up page tables, interrupt tables etc. as necessary to support running 64-bit code on the CPU, and it needs to save the full 64-bit context when switching between applications (and from applications to the kernel and back). Thus a purely 32-bit kernel can’t support 64-bit userspace.



    However a kernel can run 32-bit code in kernel space, while supporting 64-bit code in user space. That involves handling similar to the support required to run 32-bit applications with a 64-bit kernel: basically, the kernel has to support the 64-bit interfaces the applications expect. For example, it has to provide some mechanism for 64-bit code to call into the kernel, and preserve the meaning of the parameters (in both directions).



    The question then is whether it’s worth it. On the Mac, and some other systems, a case can be made since supporting 32-bit kernel code means drivers don’t all have to make the switch simultaneously. On Linux the development model is different: anything in the kernel is migrated as necessary when large changes are made, and anything outside the kernel isn’t really supported by the kernel developers. Supporting 32-bit userland with a 64-bit kernel is certainly useful and worth the effort (at least, it was when x86-64 support was added), I’m not sure there’s a case to be made for 64-bit on 32-bit...






    share|improve this answer


























    • Thanks this is helpful, although now that Gilles has pointed out his related answer on unix.stackexchange I think there's more desired for completeness. From what I gather buried there in the comment stream, apparently this is still impossible on armhf due to architectural limitations while theoretically feasible for i386? Case to be made: initial motivation was Raspbian, where the foundation's roadmap is to maintain a single kernel for years to come while retaining compatibility with the Pi Zero.

      – jdonald
      Nov 14 '18 at 21:00
















    16














    Running 64-bit applications requires some support from the kernel: the kernel needs to at least set up page tables, interrupt tables etc. as necessary to support running 64-bit code on the CPU, and it needs to save the full 64-bit context when switching between applications (and from applications to the kernel and back). Thus a purely 32-bit kernel can’t support 64-bit userspace.



    However a kernel can run 32-bit code in kernel space, while supporting 64-bit code in user space. That involves handling similar to the support required to run 32-bit applications with a 64-bit kernel: basically, the kernel has to support the 64-bit interfaces the applications expect. For example, it has to provide some mechanism for 64-bit code to call into the kernel, and preserve the meaning of the parameters (in both directions).



    The question then is whether it’s worth it. On the Mac, and some other systems, a case can be made since supporting 32-bit kernel code means drivers don’t all have to make the switch simultaneously. On Linux the development model is different: anything in the kernel is migrated as necessary when large changes are made, and anything outside the kernel isn’t really supported by the kernel developers. Supporting 32-bit userland with a 64-bit kernel is certainly useful and worth the effort (at least, it was when x86-64 support was added), I’m not sure there’s a case to be made for 64-bit on 32-bit...






    share|improve this answer


























    • Thanks this is helpful, although now that Gilles has pointed out his related answer on unix.stackexchange I think there's more desired for completeness. From what I gather buried there in the comment stream, apparently this is still impossible on armhf due to architectural limitations while theoretically feasible for i386? Case to be made: initial motivation was Raspbian, where the foundation's roadmap is to maintain a single kernel for years to come while retaining compatibility with the Pi Zero.

      – jdonald
      Nov 14 '18 at 21:00














    16












    16








    16







    Running 64-bit applications requires some support from the kernel: the kernel needs to at least set up page tables, interrupt tables etc. as necessary to support running 64-bit code on the CPU, and it needs to save the full 64-bit context when switching between applications (and from applications to the kernel and back). Thus a purely 32-bit kernel can’t support 64-bit userspace.



    However a kernel can run 32-bit code in kernel space, while supporting 64-bit code in user space. That involves handling similar to the support required to run 32-bit applications with a 64-bit kernel: basically, the kernel has to support the 64-bit interfaces the applications expect. For example, it has to provide some mechanism for 64-bit code to call into the kernel, and preserve the meaning of the parameters (in both directions).



    The question then is whether it’s worth it. On the Mac, and some other systems, a case can be made since supporting 32-bit kernel code means drivers don’t all have to make the switch simultaneously. On Linux the development model is different: anything in the kernel is migrated as necessary when large changes are made, and anything outside the kernel isn’t really supported by the kernel developers. Supporting 32-bit userland with a 64-bit kernel is certainly useful and worth the effort (at least, it was when x86-64 support was added), I’m not sure there’s a case to be made for 64-bit on 32-bit...






    share|improve this answer















    Running 64-bit applications requires some support from the kernel: the kernel needs to at least set up page tables, interrupt tables etc. as necessary to support running 64-bit code on the CPU, and it needs to save the full 64-bit context when switching between applications (and from applications to the kernel and back). Thus a purely 32-bit kernel can’t support 64-bit userspace.



    However a kernel can run 32-bit code in kernel space, while supporting 64-bit code in user space. That involves handling similar to the support required to run 32-bit applications with a 64-bit kernel: basically, the kernel has to support the 64-bit interfaces the applications expect. For example, it has to provide some mechanism for 64-bit code to call into the kernel, and preserve the meaning of the parameters (in both directions).



    The question then is whether it’s worth it. On the Mac, and some other systems, a case can be made since supporting 32-bit kernel code means drivers don’t all have to make the switch simultaneously. On Linux the development model is different: anything in the kernel is migrated as necessary when large changes are made, and anything outside the kernel isn’t really supported by the kernel developers. Supporting 32-bit userland with a 64-bit kernel is certainly useful and worth the effort (at least, it was when x86-64 support was added), I’m not sure there’s a case to be made for 64-bit on 32-bit...







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 13 '18 at 16:46

























    answered Nov 13 '18 at 7:12









    Stephen KittStephen Kitt

    167k24376454




    167k24376454













    • Thanks this is helpful, although now that Gilles has pointed out his related answer on unix.stackexchange I think there's more desired for completeness. From what I gather buried there in the comment stream, apparently this is still impossible on armhf due to architectural limitations while theoretically feasible for i386? Case to be made: initial motivation was Raspbian, where the foundation's roadmap is to maintain a single kernel for years to come while retaining compatibility with the Pi Zero.

      – jdonald
      Nov 14 '18 at 21:00



















    • Thanks this is helpful, although now that Gilles has pointed out his related answer on unix.stackexchange I think there's more desired for completeness. From what I gather buried there in the comment stream, apparently this is still impossible on armhf due to architectural limitations while theoretically feasible for i386? Case to be made: initial motivation was Raspbian, where the foundation's roadmap is to maintain a single kernel for years to come while retaining compatibility with the Pi Zero.

      – jdonald
      Nov 14 '18 at 21:00

















    Thanks this is helpful, although now that Gilles has pointed out his related answer on unix.stackexchange I think there's more desired for completeness. From what I gather buried there in the comment stream, apparently this is still impossible on armhf due to architectural limitations while theoretically feasible for i386? Case to be made: initial motivation was Raspbian, where the foundation's roadmap is to maintain a single kernel for years to come while retaining compatibility with the Pi Zero.

    – jdonald
    Nov 14 '18 at 21:00





    Thanks this is helpful, although now that Gilles has pointed out his related answer on unix.stackexchange I think there's more desired for completeness. From what I gather buried there in the comment stream, apparently this is still impossible on armhf due to architectural limitations while theoretically feasible for i386? Case to be made: initial motivation was Raspbian, where the foundation's roadmap is to maintain a single kernel for years to come while retaining compatibility with the Pi Zero.

    – jdonald
    Nov 14 '18 at 21:00













    3














    Snow leopard was able to run 64 bits binaries in an Intel 64 bit CPU.



    It was also able to boot with a 64 bit kernel when your efi was already 64 bits (my production batch of the Macbook "transition-model" pro was already such a machine).



    There was no emulation involved, you just paid a smaller performance cost when booting in 32 bits mode afair.



    In pure 32-bit CPUs, you won't be able to do that, as they have no idea how to interpret 64 bit code. Unless you are emulating with software, which would be to slow for those kind of traditionally underpowered embedded class of machines.






    share|improve this answer






























      3














      Snow leopard was able to run 64 bits binaries in an Intel 64 bit CPU.



      It was also able to boot with a 64 bit kernel when your efi was already 64 bits (my production batch of the Macbook "transition-model" pro was already such a machine).



      There was no emulation involved, you just paid a smaller performance cost when booting in 32 bits mode afair.



      In pure 32-bit CPUs, you won't be able to do that, as they have no idea how to interpret 64 bit code. Unless you are emulating with software, which would be to slow for those kind of traditionally underpowered embedded class of machines.






      share|improve this answer




























        3












        3








        3







        Snow leopard was able to run 64 bits binaries in an Intel 64 bit CPU.



        It was also able to boot with a 64 bit kernel when your efi was already 64 bits (my production batch of the Macbook "transition-model" pro was already such a machine).



        There was no emulation involved, you just paid a smaller performance cost when booting in 32 bits mode afair.



        In pure 32-bit CPUs, you won't be able to do that, as they have no idea how to interpret 64 bit code. Unless you are emulating with software, which would be to slow for those kind of traditionally underpowered embedded class of machines.






        share|improve this answer















        Snow leopard was able to run 64 bits binaries in an Intel 64 bit CPU.



        It was also able to boot with a 64 bit kernel when your efi was already 64 bits (my production batch of the Macbook "transition-model" pro was already such a machine).



        There was no emulation involved, you just paid a smaller performance cost when booting in 32 bits mode afair.



        In pure 32-bit CPUs, you won't be able to do that, as they have no idea how to interpret 64 bit code. Unless you are emulating with software, which would be to slow for those kind of traditionally underpowered embedded class of machines.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 13 '18 at 6:31

























        answered Nov 13 '18 at 6:03









        Rui F RibeiroRui F Ribeiro

        39.6k1479132




        39.6k1479132






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481382%2fwhat-does-it-take-to-run-64-bit-userland-software-on-a-32-bit-kernel%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            The Sandy Post

            Danny Elfman

            Pages that link to "Head v. Amoskeag Manufacturing Co."