• A Fatal Concertina Flaw?

    From quadibloc@quadibloc@invalid.com (John Savard) to comp.arch on Sun Nov 8 14:27:31 2026
    From Newsgroup: comp.arch

    I have been modelling the Concertina II architecture, and related
    ones, on that of the IBM System/360 in a number of ways.
    A recent thread discussing register windows led me to think of
    subroutine calling conventions. Which register windows would perhaps complicate.
    When a subroutine is called on the IBM System/360, it usually starts
    out by creating one base register value for itself by means of the
    BALR instruction. That's basically a subroutine call that doesn't go
    anywhere.
    Except for the one register that value is put in, exempted by the
    calling convention rules, the other general registers can then be
    saved in an area of data storage area located immediately after the
    program code, pointed to with the aid of the base register value set
    up which points just after the start of the program.
    But modern microprocessors, because of the increased danger from
    viruses and hackers, fix things so that the processor is allowed to
    execute instructions only from memory labelled one way - and to write
    data in memory labelled another way. And never the twain does meet -
    except with a call to the operating system being made between when the
    loader loads a program from disk into memory, and the program is
    started.
    So this IBM-style calling convention that I've built the architecture
    around is now obsolete! Save areas have to be passed to subroutines!

    John Savard
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From antispam@antispam@fricas.org (Waldek Hebisch) to comp.arch on Sun Nov 8 15:55:42 2026
    From Newsgroup: comp.arch

    John Savard <quadibloc@invalid.com> wrote:
    I have been modelling the Concertina II architecture, and related
    ones, on that of the IBM System/360 in a number of ways.
    A recent thread discussing register windows led me to think of
    subroutine calling conventions. Which register windows would perhaps complicate.
    When a subroutine is called on the IBM System/360, it usually starts
    out by creating one base register value for itself by means of the
    BALR instruction. That's basically a subroutine call that doesn't go anywhere.
    Except for the one register that value is put in, exempted by the
    calling convention rules, the other general registers can then be
    saved in an area of data storage area located immediately after the
    program code, pointed to with the aid of the base register value set
    up which points just after the start of the program.
    But modern microprocessors, because of the increased danger from
    viruses and hackers, fix things so that the processor is allowed to
    execute instructions only from memory labelled one way - and to write
    data in memory labelled another way. And never the twain does meet -
    except with a call to the operating system being made between when the
    loader loads a program from disk into memory, and the program is
    started.
    So this IBM-style calling convention that I've built the architecture
    around is now obsolete! Save areas have to be passed to subroutines!

    I wonder if you know:
    1) Successors to 360 have PC-relative addressing, so using BALR to
    capture PC usually is not needed.
    2) Save areas are normally allocated on the stack
    3) If for some reason you want save area in fixed place you can
    load its address to register. Save area does not have to be very
    close to the code (but if it is far away then you need to provide
    more bits in the instruction).
    4) While security folks insist on separate code and data areas,
    there is still a lot of code that mixes them. And arguably,
    if language checks memory accesses, then separtation does not
    provide extra security. To explain this a bit more: popular
    alternative to dynamically generated code is use of function
    pointers or intrpretive execution. But of course, overwriting
    interpretive code is as bad as overwriting native code.
    Similarly, overwriting function pointers allows executing
    arbitrary existing code and programs frequently have enough
    capabilities that the word "existing" is not a serious
    limitation to determined attacker.
    AFAICS biggest trouble is due to caches: writes go to data cache,
    code is fetched from instruction cache and at least L1 caches
    are separate. So there is synchronization overhead, but that
    should be managable.
    --
    Waldek Hebisch
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From quadibloc@quadibloc@invalid.com (John Savard) to comp.arch on Sun Nov 8 18:13:48 2026
    From Newsgroup: comp.arch

    On Sun, 8 Nov 2026 15:55:42 -0000 (UTC), antispam@fricas.org (Waldek
    Hebisch) wrote:

    I wonder if you know:
    1) Successors to 360 have PC-relative addressing, so using BALR to
    capture PC usually is not needed.

    Concertina II has PC-relative addressing, but it still also uses base
    registers for most addressing. A subroutine call with a base-relative destination address can be used in place of a BALR instruction to
    capture an address value.

    2) Save areas are normally allocated on the stack

    I know that's how most PCs work. The 360 did not have a stack at all
    in the old days. Of course, a stack can be implemented even without an
    explicit stack pointer. And I presumed this was what the successors to
    the 360 might do; define one register as the one in which a pointer to
    the save area is passed.

    3) If for some reason you want save area in fixed place you can
    load its address to register. Save area does not have to be very
    close to the code (but if it is far away then you need to provide
    more bits in the instruction).

    Huh? Can't I just use a different base register if they're far away?

    4) While security folks insist on separate code and data areas,
    there is still a lot of code that mixes them. And arguably,
    if language checks memory accesses, then separtation does not
    provide extra security.

    That argument is fallacious, since a software barrier has the obvious
    potential of being bypassed if a way to sneak in machine code can be
    found.

    To explain this a bit more: popular
    alternative to dynamically generated code is use of function
    pointers or intrpretive execution. But of course, overwriting
    interpretive code is as bad as overwriting native code.

    It's _almost_ as bad, since, of course, the interpreter can impose
    additional limits that the hardware instruction set does not impose.

    Similarly, overwriting function pointers allows executing
    arbitrary existing code and programs frequently have enough
    capabilities that the word "existing" is not a serious
    limitation to determined attacker.
    AFAICS biggest trouble is due to caches: writes go to data cache,
    code is fetched from instruction cache and at least L1 caches
    are separate. So there is synchronization overhead, but that
    should be managable.

    Machines that separate code and data are still perfectly able to use
    techniques like just-in-time compilation; the same technique is used
    as is needed for such a simple thing as loading a program from the
    disk. Make an OS call to flip the usage of the memory area involved.

    Separating code and data is an obstacle to naively coding the way
    people used to on a 360; I wasn't claiming that it was a crippling
    obstacle to such a commonly used technique.

    John Savard
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From MitchAlsup@user5857@newsgrouper.org.invalid to comp.arch on Sun Nov 8 18:30:25 2026
    From Newsgroup: comp.arch

    quadibloc@invalid.com (John Savard) posted:

    On Sun, 8 Nov 2026 15:55:42 -0000 (UTC), antispam@fricas.org (Waldek
    Hebisch) wrote:

    I wonder if you know:
    1) Successors to 360 have PC-relative addressing, so using BALR to
    capture PC usually is not needed.

    Concertina II has PC-relative addressing, but it still also uses base registers for most addressing. A subroutine call with a base-relative destination address can be used in place of a BALR instruction to
    capture an address value.

    2) Save areas are normally allocated on the stack

    I know that's how most PCs work. The 360 did not have a stack at all
    in the old days. Of course, a stack can be implemented even without an explicit stack pointer. And I presumed this was what the successors to
    the 360 might do; define one register as the one in which a pointer to
    the save area is passed.

    PL/1 (and PL/C and ALGOL) certainly had stack based local data areas.
    COBOL and FORTRAN of the era when S/360 came out were non-re-entrant.

    3) If for some reason you want save area in fixed place you can
    load its address to register. Save area does not have to be very
    close to the code (but if it is far away then you need to provide
    more bits in the instruction).

    Huh? Can't I just use a different base register if they're far away?

    He wants the save area in a page not marked "execute".

    4) While security folks insist on separate code and data areas,
    there is still a lot of code that mixes them. And arguably,
    if language checks memory accesses, then separtation does not
    provide extra security.

    That argument is fallacious, since a software barrier has the obvious potential of being bypassed if a way to sneak in machine code can be
    found.

    Which is why I want my JITs in a different process than the one executing
    JITed code.

    To explain this a bit more: popular
    alternative to dynamically generated code is use of function
    pointers or intrpretive execution. But of course, overwriting
    interpretive code is as bad as overwriting native code.

    Self-modifying code is bad wherever it rears its head.

    It's _almost_ as bad, since, of course, the interpreter can impose
    additional limits that the hardware instruction set does not impose.

    Return Oriented Programming Attacks can be prevented by not allowing
    LDs to read the code space <so they cant find the desired RET>

    Similarly, overwriting function pointers allows executing
    arbitrary existing code and programs frequently have enough
    capabilities that the word "existing" is not a serious
    limitation to determined attacker.
    AFAICS biggest trouble is due to caches: writes go to data cache,
    code is fetched from instruction cache and at least L1 caches
    are separate. So there is synchronization overhead, but that
    should be managable.

    Machines that separate code and data are still perfectly able to use techniques like just-in-time compilation; the same technique is used
    as is needed for such a simple thing as loading a program from the
    disk. Make an OS call to flip the usage of the memory area involved.

    Separating code and data is an obstacle to naively coding the way
    people used to on a 360; I wasn't claiming that it was a crippling
    obstacle to such a commonly used technique.

    John Savard
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From John Levine@johnl@taugh.com to comp.arch on Sun Nov 8 19:45:06 2026
    From Newsgroup: comp.arch

    According to John Savard <quadibloc@invalid.com>:
    On Sun, 8 Nov 2026 15:55:42 -0000 (UTC), antispam@fricas.org (Waldek
    Hebisch) wrote:

    I wonder if you know:
    1) Successors to 360 have PC-relative addressing, so using BALR to
    capture PC usually is not needed.

    Concertina II has PC-relative addressing, but it still also uses base >registers for most addressing. A subroutine call with a base-relative >destination address can be used in place of a BALR instruction to
    capture an address value.

    2) Save areas are normally allocated on the stack

    I know that's how most PCs work. The 360 did not have a stack at all
    in the old days. Of course, a stack can be implemented even without an >explicit stack pointer. And I presumed this was what the successors to
    the 360 might do; define one register as the one in which a pointer to
    the save area is passed.

    IBM 360 PL/I F allowed reentrant and recursive code, so it used the
    standard calling sequence to mangage a stack of chained dynamically
    allocated save areas.

    See Appendix C and D in this 1968 manual:

    https://bitsavers.org/pdf/ibm/360/pli/C28-6594-4_PL1_F_Programmers_Guide_Nov68.pdf
    --
    Regards,
    John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
    Please consider the environment before reading this e-mail. https://jl.ly
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From antispam@antispam@fricas.org (Waldek Hebisch) to comp.arch on Sun Nov 8 22:12:45 2026
    From Newsgroup: comp.arch

    John Savard <quadibloc@invalid.com> wrote:
    On Sun, 8 Nov 2026 15:55:42 -0000 (UTC), antispam@fricas.org (Waldek
    Hebisch) wrote:

    I wonder if you know:
    1) Successors to 360 have PC-relative addressing, so using BALR to
    capture PC usually is not needed.

    Concertina II has PC-relative addressing, but it still also uses base registers for most addressing. A subroutine call with a base-relative destination address can be used in place of a BALR instruction to
    capture an address value.

    Sure, you may need to load PC to register. Using something like
    BALR is a bit problematic. First, if there is a fixed register
    to store return address, then BALR would overwrite it before you
    had chance to save it. Second, BALR takes target address in
    register, so to land after current instruction you need to
    already know that you want to compute. So you either need a
    special case oe use version which take relative displacement
    instead of register argument. Third, modern hardware commonly
    have hardware stack of return addresses. BALR not matched
    with return causes misalignment of hardware return stack
    which may lead to multiple mispredicted returns. The
    3 problems above means that normally capturing PC must be
    a special case, so it is natural to treat it as a speparate
    instruction (even if you want to hijack one of BALR
    encoding and use it for the new instruction).

    2) Save areas are normally allocated on the stack

    I know that's how most PCs work. The 360 did not have a stack at all
    in the old days. Of course, a stack can be implemented even without an explicit stack pointer. And I presumed this was what the successors to
    the 360 might do; define one register as the one in which a pointer to
    the save area is passed.

    OS360 (and IIUC other systems from IBM) defined really baroque
    calling convention. A call at PL/1 level led to call of one
    or maybe 2 machine level subroutines to handle the convention.
    In particular save areas were allocated using dynamic memory
    allocation. Logically you get a stack, but at lower level it
    was a linked list. The effect was that PL/1 function/subroutine
    calls were quite slow.

    Modern systems use much more efficient calling conventions.
    Note that hardwarwise several modern systems have essentially
    the same support for stack(s) as 360. For example, on Risc-V
    common convention is that register x2 is used as a stack pointer.
    But you can use any other register (or none if you do not need
    stack). Function prologue on Risc-V looks like:

    addi sp, sp, -64
    sd s1, 0(sp)
    sd ra, 56(sp)
    sd s8, 48(sp)
    sd s7, 40(sp)
    sd s4, 32(sp)
    sd s3, 24(sp)
    sd s2, 16(sp)

    Above sp is alternative name for x2 (that is conventional stack
    pointer), ra is alternative name for x1 (that is conventianal
    register used to save return address). 'sd' stores 8 byte
    content of register at the adress being sum of numerical
    offset and base. AFAICS all instruction above can be easily
    translated to 360 (modulo need for extra free register).

    And yes, modern 360 uses similar calling convention. Note that
    this is pure software. On old 360 one needs to fight a bit
    restrictions on instruction set: to add a constant to register
    one may use LA (load address), but that only allows positive
    increments. So one way or another one needs extra register.
    For example one can load constant to extra register using LA,
    and then use register subtraction to adjust stack pointer.
    In corresponding epilogue one needs to add positive constant
    so LA works fine. Alternatively, one could use stack which
    grows toward higher addresses. Then adjustment in prologue
    can be done using LA, in epilogue registers used by the
    function are no longer needed, so we should have a free
    registers. But in prologue we can not use negative
    displacements, so we would have to store registers before
    adjusting stack pointer. That needs some cooperation from
    operating system: system should not interpret such stores
    as stack ovefolow and should not store anything in zone
    just above stack pointer (Unix signals normally create
    fake stack frame there).

    Actual sorting or restoring of registers is easier on 360
    thanks to STM and LDM.

    While need for a free register looks nasty at first, poor
    support for constants on 360 means that need for extra register
    to load constant into it is requent, so mandating a free
    register at function/subroutine entry looks reasonable. Also,
    address manipulations needed for PIC (position independent code)
    need extra register.

    IIUC you are trying to add decent support for constants to
    your architecture, in such case need to extra will vanish
    IIRC also successors to 360 got reasnable support for
    constants, so function prologue does not need extra register.
    However, I think that PIC in 64 bit mode needs a register.

    Anyway, any hardware problem with stack on 360 are due to
    insistence on positive displacements combined with lack of
    support for constant arguments in most of instructions.
    And those problems are solved in succesor machine and even
    on original 360 workaround is reasonably simple.

    3) If for some reason you want save area in fixed place you can
    load its address to register. Save area does not have to be very
    close to the code (but if it is far away then you need to provide
    more bits in the instruction).

    Huh? Can't I just use a different base register if they're far away?

    You need to load it first. If you compute the address based on PC,
    then clearly number of bits needed to express the difference
    depends on the distance. You can reserve one register just for
    purpose of storing base to save areas, but then you have effectively
    wasted a register. So it is not clear what would you gain by
    using such save area instead of using the register as stack pointer
    and allocating save area on the stack?

    4) While security folks insist on separate code and data areas,
    there is still a lot of code that mixes them. And arguably,
    if language checks memory accesses, then separtation does not
    provide extra security.

    That argument is fallacious, since a software barrier has the obvious potential of being bypassed if a way to sneak in machine code can be
    found.

    The point is that if you assume that attacker can break existing
    software berriers and modify pretty arbitrary writable locations
    in memory, then lack of execute permission in most cases is just
    a modest annayance. Sure, in rare cases lack of execute
    permission may stop the attack.

    To explain this a bit more: popular
    alternative to dynamically generated code is use of function
    pointers or intrpretive execution. But of course, overwriting
    interpretive code is as bad as overwriting native code.

    It's _almost_ as bad, since, of course, the interpreter can impose
    additional limits that the hardware instruction set does not impose.

    So you are beliving that easy software checks will fail, but that
    hard one will save you? Note that in first case you need to
    check operations work accoring to laguage rules: that array
    accesses are in bounds, that memory allocation actually got
    memory, that type tags match. Those checks are realtively easy
    to implement, they just decrease speed (say program may run at
    half or one third of speed of program without checks). When
    you have malicious interpreted code it can do anything that
    legal code can do, so basically all you can do is to say
    "no legal program will ever to this" or at best "this program
    will never do this". But in real life program are used to
    do interesting things, so attacker will have access to
    a lot of things.

    Similarly, overwriting function pointers allows executing
    arbitrary existing code and programs frequently have enough
    capabilities that the word "existing" is not a serious
    limitation to determined attacker.
    AFAICS biggest trouble is due to caches: writes go to data cache,
    code is fetched from instruction cache and at least L1 caches
    are separate. So there is synchronization overhead, but that
    should be managable.

    Machines that separate code and data are still perfectly able to use techniques like just-in-time compilation; the same technique is used
    as is needed for such a simple thing as loading a program from the
    disk. Make an OS call to flip the usage of the memory area involved.

    One things is trampolines on the stack. That is useful technique
    that requires executable stack. Another thing is performance of
    system calls to change permissions. IIUC on modern machines that
    is rather costly operation. Of course, there is some inherent
    cost for dynamically generated code, but generating say 200
    instructions can be reasonably fast. Hardware also can
    adjust things like branch predictors relatively fast. So
    main performace bottlneck is cache synchronization (IIUC
    at least some machines do this via complete flushing of
    instruction cache which is gross) and adjustment of
    permissions (which due to Spectre is likely to lead to
    full cache flush).

    Separating code and data is an obstacle to naively coding the way
    people used to on a 360; I wasn't claiming that it was a crippling
    obstacle to such a commonly used technique.

    John Savard
    --
    Waldek Hebisch
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From quadibloc@quadibloc@invalid.com (John Savard) to comp.arch on Mon Nov 9 02:06:01 2026
    From Newsgroup: comp.arch

    On Sun, 8 Nov 2026 22:12:45 -0000 (UTC), antispam@fricas.org (Waldek
    Hebisch) wrote:

    IIUC you are trying to add decent support for constants to
    your architecture, in such case need to extra will vanish

    Yes; since I agree with Mitch Alsup that putting constants as
    immediates within the instruction stream has a huge performance
    advantage over doing a separate fetch from memory, I felt that this
    was needed.
    And you're right - the loader can just relocate any immediate defined
    as being the value of an address.
    That's still put in a base register, though, so it's still true that a subroutine can't normally preserve all the registers of its caller.
    Which is not a disaster, since the calling convention can reserve a
    register for that purpose.
    What _would_ be intolerable would be if this limitation also meant
    that it was impossible to write an interrupt service routine on such
    an architecture. One way to solve that problem is to have a "Store
    Multiple Absolute" instruction with a 64-bit absolute address. The
    other is to have the interrupt process itself save at least one
    general register in addition to the PSW.

    John Savard
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From MitchAlsup@user5857@newsgrouper.org.invalid to comp.arch on Tue Nov 10 19:22:05 2026
    From Newsgroup: comp.arch

    quadibloc@invalid.com (John Savard) posted:

    On Sun, 8 Nov 2026 22:12:45 -0000 (UTC), antispam@fricas.org (Waldek
    Hebisch) wrote:

    IIUC you are trying to add decent support for constants to
    your architecture, in such case need to extra will vanish

    Yes; since I agree with Mitch Alsup that putting constants as
    immediates within the instruction stream has a huge performance
    advantage over doing a separate fetch from memory, I felt that this
    was needed.
    And you're right - the loader can just relocate any immediate defined
    as being the value of an address.
    That's still put in a base register, though, so it's still true that a subroutine can't normally preserve all the registers of its caller.
    Which is not a disaster, since the calling convention can reserve a
    register for that purpose.

    What _would_ be intolerable would be if this limitation also meant
    that it was impossible to write an interrupt service routine on such
    an architecture. One way to solve that problem is to have a "Store
    Multiple Absolute" instruction with a 64-bit absolute address. The

    That is effectively what I have done with Thread-State (5 cache lines
    holding Program status line, and the RF). A machine CR points at T-S,
    HW <conceptually> LDs T-S and stores T-S when needed {although other
    -|Arch may provide banks of pre-loaded T-Ss}.

    other is to have the interrupt process itself save at least one
    general register in addition to the PSW.

    Let HW do it and remain re-entrant and interruptible even in the ISR.

    John Savard
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From quadibloc@quadibloc@invalid.com (John Savard) to comp.arch on Wed Nov 11 04:05:36 2026
    From Newsgroup: comp.arch

    On Tue, 10 Nov 2026 19:22:05 GMT, MitchAlsup
    <user5857@newsgrouper.org.invalid> wrote:
    quadibloc@invalid.com (John Savard) posted:

    What _would_ be intolerable would be if this limitation also meant
    that it was impossible to write an interrupt service routine on such
    an architecture. One way to solve that problem is to have a "Store
    Multiple Absolute" instruction with a 64-bit absolute address. The

    That is effectively what I have done with Thread-State (5 cache lines
    holding Program status line, and the RF). A machine CR points at T-S,
    HW <conceptually> LDs T-S and stores T-S when needed {although other
    -|Arch may provide banks of pre-loaded T-Ss}.

    other is to have the interrupt process itself save at least one
    general register in addition to the PSW.

    Let HW do it and remain re-entrant and interruptible even in the ISR.

    What I've realized now from this is that having a code at the
    beginning of each 32 bits means that 32-bit and 64-bit immediates -
    and other 32-bit and 64-bit things, such as absolute addresses, are
    broken up. I knew that, I thought it was unfortunate, but what I
    realized now is that this means more work for the linking loader and
    so on.

    That makes Concertina III an inferior ISA in that respect.

    What I want from a plain ISA with ordinary variable-length
    instructions is 16-bit short instructions that are useful. With the
    32-bit instructions that I insist on taking a minimum of 3/4 of the
    possible opcode space, that seems impossible. However, to even get the
    paired short instructions to work, I had to make extraordinary
    compromises, and by taking that just one step further, perhaps useful
    16-bit freestanding instructions are possible.

    John Savard
    --- Synchronet 3.22a-Linux NewsLink 1.2