Seems to me the likely cause is the ridge of the roof settling. That puts outward force on the top of the walls and that movement lifts the walls because they are braced to the outside of the top of the first floor. If that's the cause, and I am not positive it is, then you need some ties between the tops of the second floor walls. Yes, it will reduce the headroom, but it may also keep things from falling down (again, if that's what is actually happening).
I'm guessing a bit but thinking the ends may not be sagging because the end walls support the ridge. You could try to see if the roof ridge is lower in the middle. The walls may also be curved, bowing out at the top mostly in the middle and sighting down them will clearly show if that is the case. Some detailed looking at things to determine what is moving is needed. It could be other things like floor sag as someone else suggested.